问题
I have an app on Heroku, where users can add images. When I update this app git push heroku master, all the images disappear, leaving only broken links. Do you know how to avoid it ?
回答1:
Heroku has particular restrictions on their filesystem, as it's read only.
You can only write into the public and tmp folders.
Though, those folders aren't persisted accross deployments.
This means you cannot rely on them to store files and images.
You need to send the files to a tierce party, like Amazon S3 or Google Cloud Storage.
Most of the file upload and image processing (like carrierwave) will allow you to send the files to S3, or any other party.
回答2:
Heroku doesn't have a persistent file store. You need to store the files on a service such as Amazon Simple Storage Solution (S3). For more information see Heroku's documentation. In addition you can check our Heroku's documentation on how to setup S3 here.
回答3:
Heroku do not preserve data on their servers so your images dissapear. Try using some external storage like Amazon S3 or store them in DB.
来源:https://stackoverflow.com/questions/17521683/updating-app-on-heroku-without-loosing-link-to-images