如何使用Carrierwave上传自定义S3元数据 [英] How to upload custom S3 metadata with Carrierwave

查看:62
本文介绍了如何使用Carrierwave上传自定义S3元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Content-Disposition标头添加到我要通过载波上传的文件中(以后不能通过URL中的查询参数进行选择).

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).

在文件上传之前,是否可以添加一些内容到AttachmentUploader模型中以帮助我完成此任务?

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

谢谢!

推荐答案

您可以在Carrierwave配置中全局设置属性-

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

并且上传器上的方法可以使用上传器可访问的数据来确定fog_attributes的适当返回值

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

这篇关于如何使用Carrierwave上传自定义S3元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆