Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails carrierwave S3 get url with Content-Disposition header

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.

like image 746
linjunhalida Avatar asked Sep 04 '25 16:09

linjunhalida


1 Answers

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

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

Read tons of documents and source code.

like image 119
linjunhalida Avatar answered Sep 07 '25 17:09

linjunhalida