目前我正在使用Amazon S3和Paperclip,允许我的用户上传与他们创建的事件相关联的图像。我的最终目标是,既然其他人可以查看此事件,就能够单击该图像并提示将其保存到他们的计算机中。目前,单击链接将在浏览器窗口中打开图像。我更愿意让它要求他们下载。所有图像仅保存在S3上,而不是本地。如果可能的话,需要隐藏暴露的S3 URL或伪装它。
这是我的当前设置
Index.html
<%= link_to 'Download Creative', event.creative.url, class: "btn btn-info" %>
Event.rb
has_attached_file :creative,
:styles => { :thumb => "150x150", :custcreative => "250x75" },
:path => ":attachment/:id/:style.:extension",
:s3_domain_url => "******.s3.amazonaws.com",
:storage => :s3,
:s3_credentials => Rails.root.join("config/s3.yml"),
:bucket => '*****',
:s3_permissions => :public_read,
:s3_protocol => "http",
:convert_options => { :all => "-auto-orient" },
:encode => 'utf8'
希望有人能帮助我。