Paperclip重新处理返回true但不更改文件夹结构

时间:2013-11-19 11:18:53

标签: ruby-on-rails amazon-web-services amazon-s3 paperclip

我的回形针有问题。我将它设置为在s3中存储我的附件,并且我有很多原始大小。问题是我需要重新处理它们,每个图像有3种不同的尺寸。我在回形针自述文件中读到#reprocess!方法可能有用。

这是我的附件的用户类:

has_attached_file :avatar, styles:
{
  large: ["135x135#", :jpg],
  thumb: ["50x50#", :jpg],
  small: ["30x30#", :jpg]
},
default_url: '/placeholders/avatars/:style.png',
url: '/system/users/:attachment/:id_partition/:style/:filename',
storage: :s3,
bucket: ENV['S3_BUCKET'],
s3_credentials: {
  :access_key_id => ENV['S3_ACCESS_KEY'],
  :secret_access_key => ENV['S3_SECRET_KEY']
}

validates_attachment :avatar,
content_type: {
  content_type: /^image\/(jpg|jpeg|pjpeg|png|x-png|gif)$/,
  message: 'is not allowed (only images)'
},
size: {
  in: 0..1.megabytes,
  message: 'is too big'
}

我还在我的development.rb和production.rb中将凭据设置为s3。当我运行再处理!在每个user.avatar对象上,它返回true但文件夹结构不会改变。

pry(#<Importer::Mugshots>)> user.avatar.reprocess!
(0.6ms)  BEGIN
(5.3ms)  UPDATE "users" SET "avatar_content_type" = '', "avatar_file_size" = 30735, "avatar_updated_at" = '2013-11-19 11:10:17.486960', "avatar_file_name" = '78398594.jpg', "updated_at" = '2013-11-19 11:10:19.001503' WHERE "users"."id" = 542025
(11.6ms)  COMMIT
=> true

我尝试更改paperclip配置以使用本地文件系统,但它没有帮助。它可能是什么?

1 个答案:

答案 0 :(得分:0)

尝试在s3_credentials哈希中移动存储桶

s3_credentials: {
 :bucket => ENV['S3_BUCKET']
 :access_key_id => ENV['S3_ACCESS_KEY'],
 :secret_access_key => ENV['S3_SECRET_KEY']
}