Can't upload images on Heroku server

蹲街弑〆低调 提交于 2019-12-04 11:56:34

In a cloud environment you should never upload images to the instance itself. Always use a central storage like for example S3 to store your uploaded files.

When you develop in a cloud environment you should always keep in mind that the current box you are running your code will only live for a certain amount of time (minutes, hours). So if the instances goes down you'll lose all your uploaded files.

Another problem can occur when you for example have 2 instances and your user uploads an image to instace x. Now when a second user tries to view the image but the load balancer will sent the request to instance y the image is not found because it doesn't exist on that instance.

For debugging your script I would add some more logging. Then in Heroku you could use :

heroku logs -t -a appname

to watch the logs of your application.

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