更新亚马逊s3存储桶中每个文件的标头
我的存储桶中有大量文件的 mime 类型不正确,并且没有设置过期时间。
我怎样才能改变它们呢?
我正在使用 Knox:
https://github.com/LearnBoost/knox
我正在尝试迭代超过它。如何获取文件夹中所有文件的列表?
当我执行此操作时,
client.get('/folder').on('response', function(res){
console.log(res)
res.on('data', function(chunk){
console.log(chunk);
});
}).end();
我看到有关 xml 文件的 ossomething,如何访问它?
I have a large number of files that have incorrect mimetypes in a bucket, as well as no expires set.
How can I change them all?
I'm using Knox:
https://github.com/LearnBoost/knox
I'm trying to iterate over it. How do I get a list of all files in a folder?
When I do this
client.get('/folder').on('response', function(res){
console.log(res)
res.on('data', function(chunk){
console.log(chunk);
});
}).end();
I see osmething about an xml file, how do I access it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您选择的库似乎没有任何对列出存储桶的本机支持。您需要构建列表请求并自行解析 XML - 底层 REST API 的文档可以在 S3 API 文档。
获得对象列表后,您可以使用 用于更新元数据的 S3 复制请求功能。只需应用此补丁,然后将
x-amz-metadata-directive: REPLACE
传递为复制请求的标头,指定与源和目标相同的键(源也必须指定存储桶!),加上您想要设置的任何其他标头。It looks like the library you have chosen does not have any native support for listing buckets. You will need to construct the list requests and parse the XML yourself - documentation for the underlying REST API can be found in the S3 API documentation.
Once you get a list of objects, you can use the S3 copy request functionality to update metadata. Just apply this patch, then pass
x-amz-metadata-directive: REPLACE
as a header to a copy request specifying the same key as source and destination (the source must specify the bucket as well!), plus any other headers you want to set.