回形针与Heroku失败
使用Paperclip在本地计算机上运行图像上传有什么可能的影响,但在部署到Heroku时却没有?
当它部署到Heroku时,图像将无法保存。
据我所知你不能直接写入Heroku的文件系统,所以我假设这是你的问题。 使用像Amazon s3这样的东西进行图像存储是有意义的。 看看这个: Heroku中的Amazon S3
配置完s3之后,您想要将回形针的has_attached_file
更改为以下内容:
has_attached_file :my_picture, :styles => { :medium => "275x275>" }, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => "user/:attachment/:style/:id.:extension"
其中s3.yml将是您定义访问键,存储桶的配置文件…
它应该看起来像这样:
production: access_key_id: [Your Key] secret_access_key: [Your Secret] bucket: [Your bucket name]
这是Paperclip开发人员撰写的另一篇指南/文章 ,它详细解释了如何将Paperclip与Heroku和S3集成