Question

I deployed my first Heroku app yesterday, and everything worked great.

In my app you can upload an image, I did and could see it on the "show" page. However, today the image disappeared. Everything else seems to work just fine. The application is working just fine on my local machine as well as on Heroku, other than the image which is not there.

What may be the problem? How can I make sure it doesn't happen again?

Était-ce utile?

La solution

Heroku does not support file uploads. The filesystem is readonly. You'll have to host your uploaded files somewhere else (or from the database, which is a bad option).

https://devcenter.heroku.com/articles/read-only-filesystem

Amazon S3 is a common choice: http://devcenter.heroku.com/articles/s3

If you are using any gems like paperclip or carrierwave for uploading, using S3 will be simple. You will have to set the S3 credentials in a config file and the gem will take care of uploading and will provide urls for the uploaded file.

Autres conseils

I suspect you may have uploaded the image to the Heroku filesystem and not an external filestore like Amazon S3. Heroku file system is temporary and not shared across dynos or restarts - which Heroku will do every day. I suspect this is what has occurred here resulting in you loosing your image.

Heroku is file system is temporary. Alternative you can save the images as a url, until you are ready for aws...

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top