Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails, paperclip and s3, prompt download or view images?

So i got successfully working Paperclip and S3 uploading in RoR 3, but it turns out that some images are prompted to download and others can be viewed in the browser. What determines this behaviour?

like image 762
David Mauricio Avatar asked Dec 10 '12 19:12

David Mauricio


2 Answers

Part of this could be browser-specific behavior based upon the MIME file type that the server is sending your browser. .png files are most often the culprit for forced download. See this SO question about the issues between IE uploads, old MIME types, etc.

If it is inconsistent on the type of picture, there is a way you can force a file to be downloaded, but no good way to force an image to be viewed in the browser.

Edit: I know that the forced download isn't rails specific, so here is the rails-specific version

like image 58
Ian M Avatar answered Nov 18 '22 18:11

Ian M


Is one of the following helps you?

Paperclip Force Download

Rails 'link_to' to Download An Image Immediately Instead of Opening it in the Browser

Both of them says to send the file to the browser as attachment.

like image 36
Adam Ocsvari Avatar answered Nov 18 '22 17:11

Adam Ocsvari