使用 Rails 3.2.1 和 Paperclip 2.6
我将 Paperclip 设置为使用 s3 作为存储。我想使用 :s3_permissions => :authenticated_read
。
在 Paperclip 更新为使用 aws-sdk
之前,我使用了 paperclip-aws
为经过身份验证的访问提供帮助的 gem。
Paperclip 有没有类似的 helper ?如果在没有 paperclip-aws
gem 的情况下将图像设置为 authenticated_read
,我如何通过 image_tag
访问图像?
最佳答案
给定附件配置如下:
has_attached_file :attachment,
:storage => :s3,
:bucket => 'MY-BUCKET',
:s3_permissions => :authenticated_read,
:s3_credentials => Rails.root.join("config/aws.yml")
您可以在附件上调用#expiring_url 方法:
record.attachment.expiring_url #=> "https..."
这是#expiring_url 的签名:
def expiring_url(time = 3600, style_name = default_style)
这允许您覆盖到期时间并指定您想要 url 的“样式”或版本。
关于ruby-on-rails - rails/回形针 : How do I display images from S3 that have authenticated_read permissions?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9299140/