ActiveStorage for S3 private files

可紊 提交于 2019-12-10 18:43:09

问题


Until now I was using Paperclip for uploading some files to S3. Some of these files are not public and Paperclip allowed to upload some files as private with the following bit :

has_attached_file :image, styles: { large: "2000x2000", small: "1200x1200", thumb: "250x250"}, :s3_permissions => :private

Now Paperclip is deprecated I am considering switching to Active Storage though I have not found any option to make some of my files private.

Is there something to tweak in Active Storage to allow this ?


回答1:


All the files are privates with the default ActiveStorage. If you want to be able to upload some files with public acl (with public url), and others with private acl (with expiring url) you can use my patch here : https://gist.github.com/dinatih/dbfdfd4e84faac4037448a06c9fdc016

from this comment : https://github.com/rails/rails/issues/31419#issuecomment-370900013



来源:https://stackoverflow.com/questions/50719769/activestorage-for-s3-private-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!