用于 S3 私有文件的 ActiveStorage [英] ActiveStorage for S3 private files
问题描述
到目前为止,我一直在使用 Paperclip 将一些文件上传到 S3.其中一些文件不是公开的,Paperclip 允许通过以下位将某些文件上传为私有文件:
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
现在不推荐使用 Paperclip 我正在考虑切换到 Active Storage,尽管我还没有找到任何将我的某些文件设为私有的选项.
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.
在 Active Storage 中有什么需要调整的地方吗?
Is there something to tweak in Active Storage to allow this ?
推荐答案
所有文件都是默认 ActiveStorage 的私有文件.如果您希望能够上传一些带有公共 acl(带有公共 url)的文件,还有一些带有私有 acl(带有过期 url)的文件,您可以在此处使用我的 补丁:https://gist.github.com/dinatih/dbfdfd4e84faac4037448a06c9fdc016
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
来自此评论:https://github.com/rails/rails/问题/31419#issuecomment-370900013
这篇关于用于 S3 私有文件的 ActiveStorage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!