Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload images on heroku server using attachment_fu plugin

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!

like image 233
Jayashri Avatar asked Dec 28 '10 12:12

Jayashri


People also ask

How do I add a picture to Heroku server?

How Does Simple File Upload Work? Simple File Upload replaces a hidden input tag that you create with an upload widget. When your user adds a file, it is uploaded to the cloud and a URL that links to that file is returned. Simple File Upload is specifically designed to work with Heroku's ephemeral filesystem.

Does Heroku support images?

Images are seamlessly delivered through a fast CDN, and much much more. Cloudinary offers comprehensive APIs and administration capabilities and is easy to integrate with any web application, existing or new. Cloudinary provides URL and HTTP based APIs that can be easily integrated with any Web development framework.

Can I store files on Heroku?

Heroku has an “ephemeral” hard drive, this means that you can write files to disk, but those files will not persist after the application is restarted. By default Active Storage uses a :local storage option, which uses the local file system to store any uploaded files.


1 Answers

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.)

like image 180
yfeldblum Avatar answered Jan 04 '23 15:01

yfeldblum