| @@ -633,9 +633,9 @@ | ||
| 633 | 633 | * Upload Single |
| 634 | 634 | * @since 1.0.0 |
| 635 | 635 | * @return boolean |
| 636 | 636 | */ |
| 637 | - public function uploadSingle($absolute_source_path, $relative_source_path, $prefix='') { | |
| 637 | + public function uploadSingle($absolute_source_path, $relative_source_path, $prefix='', $is_private = false) { | |
| 638 | 638 | if ( |
| 639 | 639 | isset($absolute_source_path) && !empty($absolute_source_path) && |
| 640 | 640 | isset($relative_source_path) && !empty($relative_source_path) |
| 641 | 641 | ) { |
| @@ -640,9 +640,16 @@ | ||
| 640 | 640 | isset($relative_source_path) && !empty($relative_source_path) |
| 641 | 641 | ) { |
| 642 | 642 | $file_name = wp_basename( $relative_source_path ); |
| 643 | 643 | if ($file_name) { |
| 644 | - $upload_path = Utils::generate_object_key($relative_source_path, $prefix); | |
| 644 | + $upload_path = Utils::generate_object_key($relative_source_path, $prefix, $is_private); | |
| 645 | + if ($upload_path === false) { | |
| 646 | + return [ | |
| 647 | + 'success' => false, | |
| 648 | + 'code' => 200, | |
| 649 | + 'message' => esc_html__('This file is marked private, but the private-media add-on is not currently active — reupload skipped to avoid exposing it.', 'media-cloud-sync') | |
| 650 | + ]; | |
| 651 | + } | |
| 645 | 652 | return $this->execute_upload($absolute_source_path, $upload_path); |
| 646 | 653 | } |
| 647 | 654 | return [ |
| 648 | 655 | 'success' => false, |
| @@ -1065,7 +1072,12 @@ | ||
| 1065 | 1072 | * Get domain URL |
| 1066 | 1073 | */ |
| 1067 | 1074 | public function get_domain($region = '') { |
| 1068 | 1075 | return $this->config['endpoint']; |
| 1076 | + } | |
| 1077 | + | |
| 1078 | + /** Exposes the already-constructed SDK client for StreamWrapper's registration — avoids reconstructing one from credentials. */ | |
| 1079 | + public function get_client() { | |
| 1080 | + return $this->S3CompatibleClient; | |
| 1069 | 1081 | } |
| 1070 | 1082 | |
| 1071 | 1083 | } |