How to upload custom S3 metadata with Carrierwave

2020-07-20 04:30发布

I want to add Content-Disposition header to a file I'm uploading with carrierwave (it's not an option to do it afterwards via query param in the URL).

Is there something I can add to the AttachmentUploader model that would help me accomplish this, before the file is uploaded?

Thanks!

1条回答
我想做一个坏孩纸
2楼-- · 2020-07-20 05:08

You can set attributes either globally in your Carrierwave config -

CarrierWave.configure do |config|
  config.fog_attributes = {'Content-Disposition' => ...}
end

or you can define it on the uploader class itself

def fog_attributes
  {'Content-Disposition' => ...}
end

and the method on the uploader can use data accessible to the uploader to determine the appropriate return value for fog_attributes

查看更多
登录 后发表回答