向 Carrierwave 添加额外标头以进行 Amazon s3 加密

发布于 2025-01-01 13:44:19 字数 1040 浏览 3 评论 0原文

简而言之
简而言之,我想知道是否可以通过载波和雾连接向 Amazon s3 发送额外的标头?

深入
我最近发现亚马逊支持客户端和服务器端文件加密。更多信息 » http://docs.amazonwebservices.com/AmazonS3/latest/dev/SSEUsingRESTAPI.html

我目前正在 Rails 应用程序中使用 Carrierwave 将文件上传到 amazon s3。
对于服务器端加密,亚马逊要求将 x-amz-server-side-encryption=AES256 添加到请求中。

所以我想弄清楚如何通过我的载波和雾发送额外的标头。

我的想法是,也许我可以使用像下面这样的fog_attribute配置行,也许这可能有效,但我不确定fog_attribute是用于特定属性还是只是一个总标题部分。

config.fog_attributes = {'x-amz-server-side-encryption' => 'AES256','Cache-Control'=>'max-age=315576000'}  # optional, defaults to {}

所以我终于把我的应用程序准备好了来测试这个,但不幸的是它不起作用。

我还发现了这个: https://github.com/geemus/fog/commit/070e2565d3eb08d0daaa258ad340b6254a9c6ef2在雾存储库中提交,这让我觉得fog_attributes方法是针对定义的属性列表的。

必须有一种方法可以让这项工作发挥作用。有人吗?

In short
In short I want to know if I can send additional headers through a carrierwave and fog connection to Amazon s3?

In depth
I recently found that amazon supports Client and Server side encryption of files. more info » http://docs.amazonwebservices.com/AmazonS3/latest/dev/SSEUsingRESTAPI.html

I'm currently using carrierwave in a rails app to upload files to amazon s3.
For server side encryption amazon asks for a header of x-amz-server-side-encryption=AES256 added to the request.

So I'm looking to figure out how to send additional headers through with my carrierwave and fog.

My thought was that maybe I could use the fog_attribute config line something like the following and maybe that might work but I'm not sure the fog_attribute is for partiular attribute or just a blanket header section.

config.fog_attributes = {'x-amz-server-side-encryption' => 'AES256','Cache-Control'=>'max-age=315576000'}  # optional, defaults to {}

So I finally got my app in shape to test this but unfortunately it didn't work.

I also found this: https://github.com/geemus/fog/commit/070e2565d3eb08d0daaa258ad340b6254a9c6ef2 commit in the fog repository that make me feel the fog_attributes method is for a defined list of attributes.

There has got to be a way to make this work. Anyone?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

少年亿悲伤 2025-01-08 13:44:19

我相信这实际上应该是正确的,但请注意,我不相信服务器端加密内容已经发布,因此您需要使用边缘雾来获得此行为。我希望尽快发布,然后就可以开始了。如果您发现仍然无法使其在边缘运行,请告诉我,我们将尝试看看可以做什么。

I believe that should actually be correct, note however that I don't believe the server side encryption stuff has been released, so you would need to use edge fog to get this behavior. I hope to do a release soon though and then it should be good to go. If you find that you still can't get it working on edge let me know though and we'll try and see what can be done.

就是爱搞怪 2025-01-08 13:44:19

我不能谈论 CarrierWave,但这适用于使用(当前)标准 Fog 发行版使用 AWS256 加密保存文件:

file.attributes[:encryption ] = "AES256"
result = file.save()

但是,这不适用于复制文件。对于复制有效的是:

fogfile.copy(@bucket_archived, newfilename, {'x-amz-server-side-encryption' => 'AES256'})

I cannot speak about CarrierWave, but this works for saving files with AWS256 encryption with the (currently) standard Fog distribution:

file.attributes[:encryption ] = "AES256"
result = file.save()

However, that does not work for copying files. What works for copying is:

fogfile.copy(@bucket_archived, newfilename, {'x-amz-server-side-encryption' => 'AES256'})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文