【发布时间】:2011-06-06 22:46:14
【问题描述】:
我在我的应用程序中使用带有 Imagemagick 的 Paperclip,使用 Amazon S3 进行存储。在开发中一切正常。但在 Heroku 的生产环境中,它无法正常工作。
图像上传到 Amazon S3,缩略图创建工作正常,因此 Paperclip、Imagemagick 和 S3 组合的部分工作正常。但由于某种原因,回形针特定的模型字段没有被填充:
imagestore_file_name:
imagestore_content_type:
imagestore_file_size:
imagestore_updated_at:
在开发中,这些都被填充了,但在 Heroku 上的生产中没有。当我尝试在生产应用程序(Heroku)中显示图像时,它说它丢失了,即使它肯定存在于 S3 中。什么可能导致此错误?感谢阅读。
详情:
ruby 1.8.7
Rails 3.0.1
Stack: bamboo-mri-1.9.2
编辑:
这是课程。 Image 类扩展了 Media,Media 扩展了 ActiveRecord::Base。
class Image < Media
attr_accessor :imagestore_file_name
attr_accessor :imagestore_content_type
attr_accessor :imagestore_file_size
attr_accessor :imagestore_updated_at
has_attached_file :imagestore,
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/amazon_s3.yml",
:path => "/:style/:filename",
:styles => { :medium => "800", :thumb => "150" }
end
这是相关的 Heroku 日志(我认为,有时在 Heroku 上很难分辨)
Parameters: {"authenticity_token"=>"a9+UnIlVH5HRetoN45IlGlGYoeEkpqQ1Qskpe4EGuHw=", "media_input"=>"", "imagestore"=>#<File:/home/slugs/44ca6411-6e76-4e7d-8239-a956dc3979c0/mnt/tmp/RackMultipart20110110-17158-10fuv0p>, "type"=>"uber", "name"=>"Star Wars", "detail"=>""}
[paperclip] identify -format %wx%h '/home/slugs/44ca6411-6e76-4e7d-8239-a956dc3979c0/mnt/tmp/stream20110110-17158-1uyk3if.jpg[0]' 2>/dev/null
[paperclip] convert '/home/slugs/44ca6411-6e76-4e7d-8239-a956dc3979c0/mnt/tmp/stream20110110-17158-1uyk3if.jpg[0]' -resize "800" '/home/slugs/44ca6411-6e76-4e7d-8239-a956dc3979c0/mnt/tmp/stream20110110-17158-1uyk3if20110110-17158-ta9egy' 2>/dev/null
[paperclip] identify -format %wx%h '/home/slugs/44ca6411-6e76-4e7d-8239-a956dc3979c0/mnt/tmp/stream20110110-17158-1uyk3if.jpg[0]' 2>/dev/null
[paperclip] convert '/home/slugs/44ca6411-6e76-4e7d-8239-a956dc3979c0/mnt/tmp/stream20110110-17158-1uyk3if.jpg[0]' -resize "150" '/home/slugs/44ca6411-6e76-4e7d-8239-a956dc3979c0/mnt/tmp/stream20110110-17158-1uyk3if20110110-17158-13448fs' 2>/dev/null
[paperclip] Saving attachments.
[paperclip] saving /original/starWarsart2.jpg
[paperclip] saving /medium/starWarsart2.jpg
[paperclip] saving /thumb/starWarsart2.jpg
[paperclip] Saving attachments.
Redirected to !!my site url is here!!
Completed 302 Found in 1029ms
以下是创建的图像记录中的相关字段:
imagestore_file_name:
imagestore_content_type:
imagestore_file_size:
imagestore_updated_at:
在开发中,这些字段有数据,我可以加载图像。但不在生产中。感谢您的帮助。
【问题讨论】:
-
我自己没有遇到过类似的事情,所以我不能肯定地说,但是您确定您使用不同的 S3 存储桶进行生产和开发吗?否则,您能否将包含回形针附件的模型的代码包含在内?当您实际尝试上传图片时,查看日志文件也会有所帮助
-
抱歉,一开始就应该包含它。我已将其编辑到问题中。感谢您的帮助。
-
你能在你的开发环境中做到这一点,但在生产模式下运行服务器吗?
标签: ruby-on-rails amazon-s3 imagemagick heroku paperclip