在我的Rails 4应用程序中,我有大量存储在S3上的图像,使用Paperclip。 图像URL看起来像这样:http://s3.amazonaws.com/bucketname/files/images/000/000/012/small/image.jpg?1366900621。
给定以下附件类:
给定以下附件类:
- 如何从S3下载并存储图像到本地?
- 然后如何调整本地存储的图像大小?
- 在不使用Paperclip的情况下将调整大小后的图像上传到另一个S3存储桶(位于路径s3/newbucket/images/{:id}/{imagesize.jpg})
class Image < ActiveRecord::Base
has_attached_file :file, styles: { thumbnail: '320x320', icon: '64x64', original: '1080x1080' }
validates_attachment :file, presence: true, content_type: { content_type: /\Aimage\/.*\Z/ }
end