Rails Heroku Paperclip Files disapperad

丶灬走出姿态 提交于 2019-12-25 12:36:14

问题


I'm developing a webapp with Rails, Paperclip and Heroku but since my last commit were I just added Google Analytics the most of the uploaded images disappeared! That's my link: http://wo42.herokuapp.com/ I don't know why that happened oO


回答1:


Heroku never used to let you write to their file-system although they have recently introduced something calld the ephemeral file-system - this article explains it. Best option is to use S3.




回答2:


The actual issue here is that when you push to Heroku your application is re-deployed, and that won't be to the same machine that you were on before (it could be anywhere at any time).

Therefore, if you were uploading images to your local dynos filesystem, only that dyno had access to those files. When you deployed, that dyno would have been destroyed and a new one created.

This is why Heroku recommend that you use a persistent backing service such as S3 to store your uploaded and persisted files. This sort of service is available to all dynos and persists across deploys.

https://devcenter.heroku.com/articles/s3



来源:https://stackoverflow.com/questions/9965809/rails-heroku-paperclip-files-disapperad

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