Reputation: 2497
I am having a strange issue that I haven't come across before and can't seem to find any additional information about it online.
I am running an app on a free instance on Heroku. With Heroku free instances the Dyno's power down after 30 mins or so if there are no requests made to the server.
The issue I am having is that images uploaded through Carrierwave Gem (integrated with Active Admin) are not being loaded when Heroku has shut down and had to restart, meaning I then have to re-upload everything?
The images are being stored on the server in the public directory.
Has anyone else had this issue before and if so do you know how to solve it? :)
Upvotes: 0
Views: 472
Reputation: 1657
On Heroku you can not save files\attachments locally on the server
Read this
https://devcenter.heroku.com/articles/read-only-filesystem
You can save to the tmp folder, BUT it is not guaranteed to stay there
In order to upload files you should use some external storage like Amazon S3 for example
Upvotes: 1
Reputation: 5041
Files stored in your dyno are lost when the dyno is restarted. This happens because a new dyno is created and files are not preserved across the dynos. Unfortunately, even a paid-for instance of Heroku will have this problem, since a new dyno is created when you push new versions.
Your solution might be limited to the options that are available through the app you are using. Some possible ideas are to place the images in a database, place images on another service provider such as Amazon S3, or host the application elsewhere.
Upvotes: 1