jrrdnx / craft-cloudflare-r2

MIT License
6 stars 3 forks source link

Errors when trying to copy/duplicate or move files & folders #6

Closed FreekVR closed 1 year ago

FreekVR commented 1 year ago

When trying to copy/duplicate a file or folder, the Flysystem S3 adapter is trying to determine the ACL for the file, which is not supported in R2. As such, trying to move any file results in an error.

2023-08-30 09:02:45 [web.ERROR] [craft\errors\FsException] GuzzleHttp\Exception\ServerException: Server error: `GET https://thejuly-r2-staging.ba3480a1e9cef1fc03b9e0656c55fd28.r2.cloudflarestorage.com//development/freek/dsc_7886_720.jpg?acl` resulted in a `501 Not Implemented` response:
<?xml version="1.0" encoding="UTF-8"?><Error><Code>NotImplemented</Code><Message>GetObjectAcl not implemented</Message>< (truncated...)
 in /var/www/html/craft/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /var/www/html/craft/vendor/guzzlehttp/guzzle/src/Middleware.php(72): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response), NULL, Array, NULL)
#1 /var/www/html/craft/vendor/guzzlehttp/promises/src/Promise.php(204): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /var/www/html/craft/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL)
#3 /var/www/html/craft/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 /var/www/html/craft/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(159): GuzzleHttp\Promise\TaskQueue->run()
#5 /var/www/html/craft/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(185): GuzzleHttp\Handler\CurlMultiHandler->tick()
#6 /var/www/html/craft/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\Handler\CurlMultiHandler->execute(true)
#7 /var/www/html/craft/vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn()
#8 /var/www/html/craft/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#9 /var/www/html/craft/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#10 /var/www/html/craft/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#11 /var/www/html/craft/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#12 /var/www/html/craft/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#13 /var/www/html/craft/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(58): GuzzleHttp\Promise\Promise->wait()
#14 /var/www/html/craft/vendor/jrrdnx/craft-cloudflare-r2/src/S3Client.php(55): Aws\AwsClient->execute(Object(Aws\Command))
#15 /var/www/html/craft/vendor/league/flysystem-aws-s3-v3/AwsS3V3Adapter.php(274): jrrdnx\cloudflarer2\S3Client->execute(Object(Aws\Command))
#16 /var/www/html/craft/vendor/league/flysystem-aws-s3-v3/AwsS3V3Adapter.php(419): League\Flysystem\AwsS3V3\AwsS3V3Adapter->visibility('dsc_7886_720.jp...')
#17 /var/www/html/craft/vendor/league/flysystem-aws-s3-v3/AwsS3V3Adapter.php(408): League\Flysystem\AwsS3V3\AwsS3V3Adapter->copy('dsc_7886_720.jp...', 'Testfolder/dsc_...', Object(League\Flysystem\Config))
#18 /var/www/html/craft/vendor/league/flysystem/src/Filesystem.php(122): League\Flysystem\AwsS3V3\AwsS3V3Adapter->move('dsc_7886_720.jp...', 'Testfolder/dsc_...', Object(League\Flysystem\Config))
#19 /var/www/html/craft/vendor/craftcms/flysystem/src/base/FlysystemFs.php(176): League\Flysystem\Filesystem->move('dsc_7886_720.jp...', 'Testfolder/dsc_...')
#20 /var/www/html/craft/vendor/craftcms/cms/src/models/Volume.php(446): craft\flysystem\base\FlysystemFs->renameFile('dsc_7886_720.jp...', 'Testfolder/dsc_...')
#21 /var/www/html/craft/vendor/craftcms/cms/src/elements/Asset.php(3092): craft\models\Volume->renameFile('dsc_7886_720.jp...', 'Testfolder/dsc_...')
#22 /var/www/html/craft/vendor/craftcms/cms/src/elements/Asset.php(2831): craft\elements\Asset->_relocateFile()
#23 /var/www/html/craft/vendor/craftcms/cms/src/services/Elements.php(3170): craft\elements\Asset->afterSave(false)

In R2, objects are currently always treated as private.

Working on a PR to workaround the issue.