From 00d52654ea08ed9a6ad192d97f7bb4776f999b57 Mon Sep 17 00:00:00 2001 From: marivaldojr Date: Tue, 6 Jul 2021 09:28:07 -0300 Subject: [PATCH] Copy using the SDK's copy method --- src/BackblazeAdapter.php | 6 +++--- tests/BackblazeAdapterTests.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/BackblazeAdapter.php b/src/BackblazeAdapter.php index 6468a40..7de9fbe 100755 --- a/src/BackblazeAdapter.php +++ b/src/BackblazeAdapter.php @@ -146,11 +146,11 @@ public function rename($path, $newpath) */ public function copy($path, $newPath) { - return $this->getClient()->upload([ + return $this->getClient()->copy([ 'BucketId' => $this->bucketId, 'BucketName' => $this->bucketName, - 'FileName' => $newPath, - 'Body' => @file_get_contents($path), + 'FileName' => $path, + 'SaveAs' => $newPath, ]); } diff --git a/tests/BackblazeAdapterTests.php b/tests/BackblazeAdapterTests.php index 65906bb..a6ce622 100644 --- a/tests/BackblazeAdapterTests.php +++ b/tests/BackblazeAdapterTests.php @@ -148,9 +148,9 @@ public function testGetMimetype($adapter, $mock) public function testCopy($adapter, $mock) { $this->fileSetUp(); - $mock->upload(['BucketId' => null, 'BucketName' => 'my_bucket', 'FileName' => 'something_new', 'Body' => ''])->willReturn(new File('something_new', '', '', '', ''), false); - $result = $adapter->copy($this->file_mock->url(), 'something_new'); - $this->assertObjectHasAttribute('id', $result, 'something_new'); + $mock->copy(['BucketId' => null, 'BucketName' => 'my_bucket', 'FileName' => 'something_old', 'SaveAs' => 'something_new'])->willReturn(new File('random_id', 'something_new', '', '', ''), false); + $result = $adapter->copy('something_old', 'something_new'); + $this->assertObjectHasAttribute('id', $result); } /**