PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
← All changes | includes/sdk/s3/Aws/S3/ObjectUploader.php +5 -2 1.0.2 → 1.4.2 View file →
@@ -19,8 +19,9 @@
19 19 private $body;
20 20 private $acl;
21 21 private $options;
22 22 private static $defaults = ['before_upload' => null, 'concurrency' => 3, 'mup_threshold' => self::DEFAULT_MULTIPART_THRESHOLD, 'params' => [], 'part_size' => null];
23 + private $addContentMD5;
23 24 /**
24 25 * @param S3ClientInterface $client The S3 Client used to execute
25 26 * the upload command(s).
26 27 * @param string $bucket Bucket to upload the object, or
@@ -44,13 +45,15 @@
44 45 $this->key = $key;
45 46 $this->body = Psr7\Utils::streamFor($body);
46 47 $this->acl = $acl;
47 48 $this->options = $options + self::$defaults;
49 + // Handle "add_content_md5" option.
50 + $this->addContentMD5 = isset($options['add_content_md5']) && $options['add_content_md5'] === \true;
48 51 }
49 52 /**
50 53 * @return PromiseInterface
51 54 */
52 - public function promise()
55 + public function promise() : PromiseInterface
53 56 {
54 57 /** @var int $mup_threshold */
55 58 $mup_threshold = $this->options['mup_threshold'];
56 59 if ($this->requiresMultipart($this->body, $mup_threshold)) {
@@ -57,9 +60,9 @@
57 60 // Perform a multipart upload.
58 61 return (new MultipartUploader($this->client, $this->body, ['bucket' => $this->bucket, 'key' => $this->key, 'acl' => $this->acl] + $this->options))->promise();
59 62 }
60 63 // Perform a regular PutObject operation.
61 - $command = $this->client->getCommand('PutObject', ['Bucket' => $this->bucket, 'Key' => $this->key, 'Body' => $this->body, 'ACL' => $this->acl] + $this->options['params']);
64 + $command = $this->client->getCommand('PutObject', ['Bucket' => $this->bucket, 'Key' => $this->key, 'Body' => $this->body, 'ACL' => $this->acl, 'AddContentMD5' => $this->addContentMD5] + $this->options['params']);
62 65 if (\is_callable($this->options['before_upload'])) {
63 66 $this->options['before_upload']($command);
64 67 }
65 68 return $this->client->executeAsync($command);