在Amazon S3的桶更新每一个文件的标题 [英] updating headers of every file in an amazon s3 bucket

查看:281
本文介绍了在Amazon S3的桶更新每一个文件的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大量的有不正确的MIME类型水桶的文件,并没有过期设置。

I have a large number of files that have incorrect mimetypes in a bucket, as well as no expires set.

如何改变它们?

我使用诺克斯:

https://github.com/LearnBoost/knox

我想迭代它。我如何获得一个文件夹中的所有文件的清单?

I'm trying to iterate over it. How do I get a list of all files in a folder?

当我这样做

  client.get('/folder').on('response', function(res){
    console.log(res)
    res.on('data', function(chunk){
      console.log(chunk);
    });
  }).end();

我看到osmething大约一个XML文件,我怎么访问它?

I see osmething about an xml file, how do I access it?

推荐答案

看起来你已经选择不具备上市桶任何原生支持库。您将需要构建的请求列表和解析自己的XML - 为底层REST API文档可以在的 S3 A​​PI文档。

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.

一旦你得到对象的列表,你可以使用到 S3副本请求功能更新元数据。只需应用该补丁,然后通过 X-AMZ-元数据指令:更换作为复制请求指定相同的键源和目标(源必须指定桶的!),再加上你想设置的任何其他头标题。

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.

这篇关于在Amazon S3的桶更新每一个文件的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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