我想下载一张使用carrierwave上传到S3的图片。图像在卡片模型上,作为上传器安装。我看到了这个答案,但无法让该解决方案发挥作用。我的代码是:
#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!
最后一行抛出:“......导致异常(nil:NilClass的未定义方法'body')......”
我的carrierwave配置如下:
#config/initializers/carrierwave.rb
CarrierWave.configure do |config|
config.storage = :fog
config.cache_dir = "#{Rails.root}/tmp/upload"
...
end