开发者

Paperclip Refreshing of Thumbnails not working with S3

开发者_Go百科

I have Paperclip installed as a gem and i am trying to refresh the thumbnail size of the images. I'm running this command:

rake paperclip:refresh:thumbnails CLASS=User

and receiving this error:

...rake aborted! The specified key does not exist.

Any ideas?

Finn


An instance of the User model does not have an associated thumbnail. Ie. the user has not uploaded a thumbnail. The reprocess! method doesn't check if an thumbnail exists for each model instance before trying to retrieve the attachment. Therefore, S3 returns:

NoSuchKey The specified key does not exist.

Or it could be due to a bug in S3 attachment handling:

http://github.com/tomafro/paperclip/commit/64ae23ba01885e22cc69bf1264f339784ce32fc9


Most likely you have attachments uploaded before you changed your attachment settings to S3. So for instance if you:

1) Uploaded an attachment with the configuration set to use the filesystem for storage 2) Changed your settings to use S3 3) Upload more images 4) call rake paperclip:refresh:thumbnails

... you will get an error for all the images uploaded in Step 1. The solution is to just go through and clear all the old attachments. You can do this by calling

user.attachment.clear

The only problem is that it'll still try to delete those images off of S3, where they don't exist, so to get by this problem, you have to add the :preserve_files => true option to your has_attached_file before you start clearing the old attachments. Just make sure to remove the :preserve_files => true when you're done.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜