我想使用carrierwave下载上传到S3的图像.图像位于卡型号上,作为上传器安装.我看到
this answer,但无法使该解决方案起作用.我的代码是:
#download image from S3
uploader = card.image #image is the mounted uploader
uploader.retrieve_from_store!(File.basename(card.image.url))
uploader.cache_stored_file!
最后一行抛出:“…导致异常(未定义的方法`body’为nil:NilClass)……”
我的carrierwave配置如下:
#config/initializers/carrierwave.rb
CarrierWave.configure do |config|
config.storage = :fog
config.cache_dir = "#{Rails.root}/tmp/upload"
...
end
最佳答案 谢谢
apneadiving.它很简单:
image = MiniMagick::Image::open(card.image.to_s)
image.write(somepath)