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?
Asked
Active
Viewed 254 times
8
-
I believe the assets pipeline is what determines this behavior. – Sully Dec 10 '12 at 19:55
-
Right, then how to properly take control of the default action? – damuz91 Dec 10 '12 at 19:57
-
Where do they get called to be prompted/displayed in your app? – Sully Dec 10 '12 at 20:03
-
In the show page of my model, i have got a gallery. When i click in some images the browser navigates to the image url and displays it, some other are just prompted to download. – damuz91 Dec 10 '12 at 20:07
-
facing the same problem – avimehenwal Oct 16 '13 at 08:04
2 Answers
1
Is one of the following helps you?
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.

Community
- 1
- 1

Adam Ocsvari
- 8,056
- 2
- 17
- 30
1
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