细粒度的“公共”;使用 Fog 和 Carrierwave 上传文件的设置
我正在创建一个 Rails 应用程序,允许管理员上传可以选择公开显示的照片。对于上传/存储过程,我使用 Carrierwave gem 以及 Fog gem 和 S3。问题是,为了让这一切正常工作,我必须将上传到 s3 存储桶的每个文件公开。有没有办法在逐个文件的基础上使文件公开/私有?另外,如果这种逐个文件的粒度是可能的,它是否可以扩展到图像版本(通过自动 Carrierwave 调整大小创建)?
目前,我的载波初始值设定项中有以下行:
config.fog_public = true
I am creating a rails app that lets an administrator upload photos that are optionally publicly displayed. For the upload / storage process I am using the Carrierwave gem along with the Fog gem and S3. The issue is that in order to get this all working, I have to make every file uploaded to the s3 bucket public. Is there a way to make files public / private on a file-by-file basis? Also, if this file-by-file granularity is possible, can it extend down to versions of images (created by automatic Carrierwave resizing)?
Currently, I have the following line in my carrierwave initializer:
config.fog_public = true
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实上,Carrierwave 非常简单。
你可以这样做:
或者(未经测试,但应该可以完美工作)这个:
:-)
我还没有尝试过 DragonFly,但现在 Carrierwave 在过去 2 个月中已经解决了一些问题,它远远优于我的其他任何东西见过。非常灵活。
//哑光
Actually, it's dead simple in Carrierwave.
You can do this:
Or (untested but should work perfectly) this:
:-)
I haven't tried DragonFly, but now that a couple of issues have been fixed in the last 2 months with Carrierwave, it's far superior to anything else I've seen. Insanely flexible.
//matt
只需让您的上传器类覆盖基类即可。我今天也把头发扯掉了.. :( 这对我有用:
使用 Carrierwave 0.8.0 (2013 年 5 月)
/app/uploaders/whatever_uploader.rb
Just have to make your uploader class override the base class. I tore my hair out today too.. :( This worked for me:
Using Carrierwave 0.8.0 (in May 2013)
/app/uploaders/whatever_uploader.rb