用于 S3 私有文件的 ActiveStorage

2024-06-19

到目前为止,我一直在使用 Paperclip 将一些文件上传到 S3。其中一些文件不是公开的,Paperclip 允许通过以下位将一些文件作为私有文件上传:

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

现在 Paperclip 已被弃用,我正在考虑切换到 Active Storage,尽管我还没有找到任何选项来将我的某些文件设为私有。

Active Storage 中是否需要进行一些调整才能实现此目的?


所有文件都是默认 ActiveStorage 的私有文件。 如果您希望能够使用公共 acl(带有公共 url)上传一些文件,而使用私有 acl(带有过期 url)上传其他文件,您可以使用我的patch here : https://gist.github.com/dinatih/dbfdfd4e84faac4037448a06c9fdc016 https://gist.github.com/dinatih/dbfdfd4e84faac4037448a06c9fdc016

来自这个评论:https://github.com/rails/rails/issues/31419#issuecomment-370900013 https://github.com/rails/rails/issues/31419#issuecomment-370900013

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

用于 S3 私有文件的 ActiveStorage 的相关文章

随机推荐