图片在Heroku上消失了 [英] Picture disappeared on Heroku

查看:157
本文介绍了图片在Heroku上消失了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我昨天部署了我的第一个Heroku应用程序,并且一切都很顺利。



在我的应用程序中,您可以上传图片,我可以在显示页面中看到它。但是,今天的形象消失了。其他一切似乎都很好。该应用程序在我的本地机器以及Heroku上都可以正常工作,除了不存在的映像之外。



可能是什么问题?我怎样才能确保它不会再发生?

解决方案

Heroku不支持文件上传。该文件系统是只读的。您将
必须将您上传的文件托管在其他地方(或从数据库,这是一个不好的选择)。

//devcenter.heroku.com/articles/read-only-filesystemrel =noreferrer> https://devcenter.heroku.com/articles/read-only-filesystem



亚马逊S3是一种常见的选择: http://devcenter.heroku.com/文章/ s3



如果您使用回形针或载波上传任何宝石,使用S3将会很简单。您将不得不在配置文件中设置S3凭证,并且该宝石将负责上传并为上传的文件提供URL。


I deployed my first Heroku app yesterday, and everything worked great.

In my app you can upload an image, I did and could see it in the "show" page. However today the image disappeared. Everything else seems to work just fine. The application is working just fine on my local machine as well as on Heroku, other than the image which is not there.

What may be the problem? How can I make sure it doesn't happen again?

解决方案

Heroku does not support file uploads. The filesystem is readonly. You'll have to host your uploaded files somewhere else (or from the database, which is a bad option).

https://devcenter.heroku.com/articles/read-only-filesystem

Amazon S3 is a common choice: http://devcenter.heroku.com/articles/s3

If you are using any gems like paperclip or carrierwave for uploading, using S3 will be simple. You will have to set the S3 credentials in a config file and the gem will take care of uploading and will provide urls for the uploaded file.

这篇关于图片在Heroku上消失了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆