How to upload images on heroku server using attachment_fu plugin
Asked Answered
C

1

6

I have an app in Heroku, I need simple file storage for uploaded images for this I used send_data using attachment_fu plugin. After that I have used the tmp/ directory to write this file and want to display on browser, But these files are not displayed in browser. How can I display these images on browser?

What is the alternate solution to store and retrieve images?

Thanks!

Chloral answered 28/12, 2010 at 12:56 Comment(0)
P
13

You cannot store uploaded files on Heroku.

You must use an alternative strategy. A couple alternative strategies:

  1. Store uploaded files in your database on Heroku. Because database systems are not specifically optimized for storing files, you should test out how well your application performs under load before you use this strategy.

  2. Store uploaded files in an external storage service. Amazon S3 is a popular cloud storage service that anyone can use, and it has pay-as-you-go pricing just like Heroku. (In fact, Heroku itself runs on top of another of Amazon's cloud services, EC2.)

Proselyte answered 28/12, 2010 at 15:23 Comment(2)
I have used database to store the uploaded images. I want to display these images on browser, if I used public/ file to temporary write file from database then it displays on browser. But when I used temp/ file to write this images it will not displayed on browser. Why this happens? Can I display images from temp/ file?Chloral
You can use something like send_data @record_with_image.raw_image_data, :type => 'application/png'. But you cannot store files permanently on disk on Heroku, nor can you make temp files and then serve the temp files directly to the user. You must either render the files using the Rack stack or store the files using some external service.Proselyte

© 2022 - 2024 — McMap. All rights reserved.