Rails carrierwave S3 get url with Content-Disposition header

戏子无情 提交于 2020-02-04 01:32:31

问题


We are using carrierwave + aws S3 to upload file, and we need provide a download function.

For solution 1, we use:

= link_to "Download", file.doc.url, download: file.original_name

And it does not work under IE8, click the link will open this file(image).

According to This, I should add Content-Disposition header,

Then I check aws S3 document, Found I need add response-content-disposition to file.doc.url,

Is there any way I can do this in carrierwave, or I could use other ways? Thanks for your help.


回答1:


Got it, for fu = FileUploader.new, we can use:

fu.url(query: {"response-content-disposition" => "attachment;"})

Read tons of documents and source code.



来源:https://stackoverflow.com/questions/24947512/rails-carrierwave-s3-get-url-with-content-disposition-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!