【发布时间】:2015-06-18 21:51:29
【问题描述】:
我有一个使用回形针和 s3 上传文件附件的项目。我怎样才能让用户下载这些文件。
型号
class Assets
has_attached_file :file
end
路线
resources :assets do
member do
get 'download'
end
end
控制器
def download
data = open(@asset.file.url)
send_data data.read, :type => data.content_type, :x_sendfile => true, :url_based_filename => true
end
错误:
AssetsController#download 中的 OpenURI::HTTPError
403 禁止
【问题讨论】:
-
网络上有无数的资源,因此涵盖了这一点。建议你先看看这些,如果你遇到困难(代码,错误等),尝试自己做这个和帖子。
-
我对此尝试了不同的解决方案,但我不清楚。
-
@steveklein 我提供了有关我正在从事的工作的更多信息
标签: ruby-on-rails-4 amazon-s3 paperclip