Updating app on Heroku without loosing link to images

我与影子孤独终老i 提交于 2020-01-04 16:57:36

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!