shrinerb / shrine

File Attachment toolkit for Ruby applications
https://shrinerb.com
MIT License
3.18k stars 275 forks source link

Using Shrine with Cloudflare R2 causes error Aws::S3::Errors::NotImplemented - x-amz-tagging #662

Closed dylandamsma closed 6 months ago

dylandamsma commented 11 months ago

Issue: I've implemented Shrine with Cloudflare R2 S3-compatible object storage. However, when uploading an image, I get this error back from Cloudflare: Aws::S3::Errors::NotImplemented (Header 'x-amz-tagging-directive' with value 'REPLACE' not implemented).

As per their documentation, this is indeed not yet implemented: https://developers.cloudflare.com/r2/api/s3/api/

This issue only occurs when generating / using derivatives

Question: Is it possible to use Shrine with R2 at the moment? Is it possible to disable or bypass this x-amz-tagging?

Note: It's to note I saw a recent posted where another user was also using Cloudflare R2, which suggested to me it is in fact usable.

hkdahal commented 11 months ago

I've identified/narrowed down that this only occurs when using cache store in Cloudflare. This doesn't occur when when using cache store via Filesystem and uploading to Cloudflare store.

It'd be great if we can get similar behavior when using cache in Cloudflare.

hkdahal commented 11 months ago

@dylandamsma - I've opened a PR to fix this: https://github.com/shrinerb/shrine/pull/663. In the meantime, I'm using this forked version (https://github.com/nebham/shrine) in my code.

manuca commented 9 months ago

I also faced this issue. No derivatives, just using R2 for cache and store.

If I cache on the filesystem and store on R2 it does work however.

BTW I also realized R2 doesn't support direct uploads via POST requests unfortunately. For folks looking to use that feature that Shrine supports for S3.

thatdom commented 6 months ago

+1

janko commented 6 months ago

Should be fixed by https://github.com/shrinerb/shrine/pull/663.

legendetm commented 1 month ago

We use shrinerb and s3 to upload files to AWS, Google and Alibaba, and we also had to disable the X-Amz-Tagging. So it's seems the tagging option is not implemented in multiple S3 compatible providers.

As the error message is general "NotImplemented - A header you provided implies functionality that is not implemented", maybe it would be good to add some notes to README, that if non AWS provider is used and you get NotImplemented error, you may need to disable tagging directive.

jrochkind commented 1 month ago

I wonder if it would make sense to create additional adapters for "S3-kind-of-compatible", either for specific ones or a general one with common things discovered in common? It could certainly be done in another repo as a "third party" if someone were interested! It/they could be sub-classes of S3 adapter with over-rides. Say removing tagging as a feature entirely.

legendetm commented 1 month ago

For me the only issue with S3 compatible storage providers have been the tagging-directive for basic usage.

I would recommend to either make it opt-in or mention that in README, as I understand this is not supported by multiple S3-kind-of-compatible providers. Also It would be nice to mention this as possible breaking change in CHANGELOG for S3-kind-of-compatible providers.

Internally we check if s3 endpoint is given, and if then we remove the tagging_directive option.