简体   繁体   English

如何使用Carrierwave上传自定义S3元数据

[英]How to upload custom S3 metadata with Carrierwave

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). 我想将Content-Disposition标头添加到我正在使用carrierwave上传的文件中(之后通过URL中的查询参数不能选择它)。

Is there something I can add to the AttachmentUploader model that would help me accomplish this, before the file is uploaded? 在上传文件之前,我可以添加到AttachmentUploader模型中以帮助我完成此操作吗?

Thanks! 谢谢!

You can set attributes either globally in your Carrierwave config - 您可以在Carrierwave配置中全局设置属性 -

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 并且上传者的方法可以使用上传者可访问的数据来确定fog_attributes的适当返回值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM