回形针瓦特/ ImageMagick的,Amazon S3和Heroku的 - ImageMagick的&放大器; S3的工作,但回形针领域不要在数据库中设置。做工精细的开发回形针、放大器、数据库中

2023-09-11 23:44:02 作者:来我怀里

我用回形针与ImageMagick的在我的应用程序,使用Amazon S3存储。一切正常的发展。但在生产中在Heroku它不能正常工作。

I'm using Paperclip with Imagemagick in my app, using Amazon S3 for storage. Everything works fine in development. But in production on Heroku it's not working correctly.

图片被上传到Amazon S3,以及缩略图创建工作,所以回形针,ImageMagick的和S3组合的部分工作正常。但由于某些原因,回形针具体型号字段没有得到填补:

The image gets uploaded to Amazon S3, and the thumbnail creation works, so that part of the Paperclip, Imagemagick and S3 combo is working ok. But for some reason, the Paperclip specific model fields are not getting filled:

imagestore_file_name: 
imagestore_content_type: 
imagestore_file_size: 
imagestore_updated_at: 

在发展,这些都得到填充,但不是在在Heroku生产。当我尝试显示在生产中的应用程序(Heroku的)的图像,它说,它缺少,即使它是肯定存在的S3。这可能是造成这个错误?感谢您的阅读。

In development, these all get filled in, but not in production on Heroku. When I try to display an image in production app (Heroku), it says that it's missing, even though it is definately there in S3. What could be causing this error? Thanks for reading.

详细信息:

ruby 1.8.7
Rails 3.0.1
Stack: bamboo-mri-1.9.2

编辑:

下面是类。形象类扩展介质,它扩展的ActiveRecord :: Base的。

Here is the class. The Image class extends Media, which extends 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上有时)

Here is the relevant Heroku log (I think, can be hard to tell on Heroku sometimes)

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

下面是创建的图像记录的相关字段:

Here are the relevant fields from the Image record that is created:

  imagestore_file_name: 
  imagestore_content_type: 
  imagestore_file_size: 
  imagestore_updated_at:

在发展,这些领域有数据,我能加载图像。但不是在生产。感谢您的帮助。

In development, these fields have data and I am able to load the images. But not in production. Thanks for your help.

推荐答案

我认为这个问题是您所指定attr_accessor的回形针属性。那是不需要的。事实上,我得到了同样的问题,因为你在我添加这些行到我的模型。所以它应该是足够的,除去这些行。

I think the problem is that you have specified attr_accessor for the paperclip attributes. That is not needed. I actually got the same problem as you when I added those lines to my model. So it should be enough to remove those lines.