Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
369 views
in Technique[技术] by (71.8m points)

ruby on rails - How to default ActionText direct uploads to public using DigitalOcean Spaces?

Out of the box, ActionText supports public direct uploads to AWS S3, Google Cloud Storage and Azure. You need to configure the bucket to default to public-read and ensure you have public: true declared in your storage.yml file. This is well documented:

https://edgeguides.rubyonrails.org/active_storage_overview.html#public-access

The problem I'm trying to solve is that this doesn't work out of the box with DigitalOcean Spaces, despite this being billed as an S3-compatible API. The direct uploads work fine, but the files are stored in Spaces as private not public-read.

I have been back and forth with DigitalOcean support on this and it is possible to use s3cmd to put files to the Space with public read permissions (pass the --acl-public flag). So the problem appears to be with ActionText/ActiveStorage.

From what I can gather, there is a header x-amz-acl: public-read which must be sent with the request. Rails/ActiveStorage/ActionText doesn't seem to support this, which is why the feature doesn't work with DigitalOcean Spaces.

Can anyone help me develop a fix for this? Does it require a patch to Rails? Do I need to develop a new DigitalOceanStorage class that somehow sets this header?

There is a fix suggested on this Rails issue but unfortunately this is for people writing their own DirectUpload code, not for people trying to do this via ActionText/ActiveStorage from what I can tell.

Help/ideas gratefully received!

question from:https://stackoverflow.com/questions/65652310/how-to-default-actiontext-direct-uploads-to-public-using-digitalocean-spaces

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...