flownative / flow-aws-s3

Amazon S3 adaptor for Neos and Flow
MIT License
18 stars 33 forks source link

Error with s3 compatible storage and urlencode #66

Open beathorst opened 1 year ago

beathorst commented 1 year ago

In our setup (PHP 8.2, neos 8.3 and flownative/aws-s3 2.6.2) we get an error wen uploading a new image. The problem ist that we do not use aws s3. The implementation of out s3 provider gets an error with urlencode

Error: test-neos-storage%2F47d092664c3c6f3fd583321a04442102be0cf14d Has to be: test-neos-storage/47d092664c3c6f3fd583321a04442102be0cf14d

with this it would work, but I don't know if it breaks something else

return urlencode($storage->getBucketName()) . '/' . $storage->getKeyPrefix() . urlencode($resource->getSha1());

https://github.com/flownative/flow-aws-s3/blob/v2.6.2/Classes/S3Target.php#L378

23-09-20 09:48:07 127        ERROR                          ResourcePublishingMessage: Could not publish resource with SHA1 hash 47d092664c3c6f3fd583321a04442102be0cf14d (source object: test-neos-storage%2F47d092664c3c6f3fd583321a04442102be0cf14d) through "CopyObject" because the S3 client reported an error: Error executing "CopyObject" on "https://object.storage.eu01.onstackit.cloud/test-neos/47d092664c3c6f3fd583321a04442102be0cf14d/test-2.png"; AWS HTTP error: Client error: `PUT https://object.storage.eu01.onstackit.cloud/test-neos/47d092664c3c6f3fd583321a04442102be0cf14d/test-2.png` resulted in a `400 Bad Request` response:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidBucketName</Code><Message>The specified bucket is not valid.< (truncated...)
 InvalidBucketName (client): The specified bucket is not valid. - <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidBucketName</Code><Message>The specified bucket is not valid.</Message><Resource>/test-neos/47d092664c3c6f3fd583321a04442102be0cf14d/test-2.png</Resource><RequestId>1695203287484898</RequestId></Error>