重新生成大拇指时的回形针问题

Mar*_*tin 4 ruby ruby-on-rails ruby-on-rails-3

我正在尝试重新制作所有拇指.我不确定为什么说密钥不存在.我正确配置了AWS-S3并且运行良好(我可以上传图片而没有任何问题.)

>> Attachment.all.each {|x|x.attachment.reprocess!}
AWS::S3::NoSuchKey: The specified key does not exist.
    /app/d999782b-a789-4763-ac86-e8c65fa781eb/home/.bundle/gems/ruby/1.8/gems/aws-s3-    0.6.2/lib/aws/s3/error.rb:38:in `raise'
/app/d999782b-a789-4763-ac86-e8c65fa781eb/home/.bundle/gems/ruby/1.8/gems/aws-s3-0.6.2/lib/aws/s3/base.rb:72:in `request'
/app/d999782b-a789-4763-ac86-e8c65fa781eb/home/.bundle/gems/ruby/1.8/gems/aws-s3-0.6.2/lib/aws/s3/base.rb:88:in `get'
/app/d999782b-a789-4763-ac86-e8c65fa781eb/home/.bundle/gems/ruby/1.8/gems/aws-s3-0.6.2/lib/aws/s3/object.rb:134:in `value'
Run Code Online (Sandbox Code Playgroud)

当我尝试对单个对象做同样的事情似乎做得很好时,所以问题似乎与使用集合生成有关.

>> Attachment.last.attachment.reprocess!
=> true
Run Code Online (Sandbox Code Playgroud)

更新:我很确定这与上传的文件如.htm相关,这些文件应该是有效的图像文件.知道如何跳过它们吗?

Roh*_*hit 9

虽然我不确定,但我希望这对你有帮助.

Attachment.all.each { |x| x.attachment.reprocess! if ['.jpeg','.jpg','.png','.gif'].include?(File.extname(file_name))}
Run Code Online (Sandbox Code Playgroud)

哪里 file_name => Name of the uploaded file

最好的运气


har*_*ald 7

不确定您将密钥放在AWS-S3的哪个位置,但您可能必须指定要在生产环境下运行它.

heroku rake paperclip:refresh CLASS=Attachment RAILS_ENV=production
Run Code Online (Sandbox Code Playgroud)