Skip to content

Commit

Permalink
Merge pull request #40577 from nextcloud/s3-multipart-copy-27
Browse files Browse the repository at this point in the history
  • Loading branch information
juliushaertl committed Oct 10, 2023
2 parents b2c864d + 22556a6 commit 1f4fffc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 1 addition & 4 deletions apps/files_external/lib/Lib/Storage/AmazonS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,10 +580,7 @@ public function copy($source, $target, $isFile = null) {

if ($isFile === true || $this->is_file($source)) {
try {
$this->getConnection()->copyObject([
'Bucket' => $this->bucket,
'Key' => $this->cleanKey($target),
'CopySource' => S3Client::encodeKey($this->bucket . '/' . $source),
$this->copyObject($source, $target, [
'StorageClass' => $this->storageClass,
]);
$this->testTimeout();
Expand Down
16 changes: 12 additions & 4 deletions lib/private/Files/ObjectStore/S3ObjectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
namespace OC\Files\ObjectStore;

use Aws\S3\Exception\S3MultipartUploadException;
use Aws\S3\MultipartCopy;
use Aws\S3\MultipartUploader;
use Aws\S3\S3Client;
use GuzzleHttp\Psr7;
Expand Down Expand Up @@ -189,9 +190,16 @@ public function objectExists($urn) {
return $this->getConnection()->doesObjectExist($this->bucket, $urn, $this->getSSECParameters());
}

public function copyObject($from, $to) {
$this->getConnection()->copy($this->getBucket(), $from, $this->getBucket(), $to, 'private', [
'params' => $this->getSSECParameters() + $this->getSSECParameters(true)
]);
public function copyObject($from, $to, array $options = []) {
$copy = new MultipartCopy($this->getConnection(), [
"source_bucket" => $this->getBucket(),
"source_key" => $from
], array_merge([
"bucket" => $this->getBucket(),
"key" => $to,
"acl" => "private",
"params" => $this->getSSECParameters() + $this->getSSECParameters(true)
], $options));
$copy->copy();
}
}

0 comments on commit 1f4fffc

Please sign in to comment.