Is it possible to change headers on an S3 object without downloading the entire object?

后端 未结 6 1822
悲哀的现实
悲哀的现实 2020-12-08 09:59

I\'ve uploaded a bunch of images to Amazon S3, and now want to add a Cache-Control header to them.

Can the header be updated without downloading the entire image? I

6条回答
  •  Happy的楠姐
    2020-12-08 10:26

    This is out of beta and is available by doing a put command and copying the object as documented here. It is also available in their SDK's. For example with C#:

    var s3Client = new AmazonS3Client("publicKey", "privateKey");
    var copyRequest = new CopyObjectRequest()
                      .WithDirective(S3MetadataDirective.REPLACE)
                      .WithSourceBucket("bucketName")
                      .WithSourceKey("fileName")
                      .WithDestinationBucket("bucketName")
                      .WithDestinationKey("fileName)
                      .WithMetaData(new NameValueCollection { { "x-amz-meta-yourKey", "your-value }, { "x-amz-your-otherKey", "your-value" } });
    var copyResponse = s3Client.CopyObject(copyRequest);
    

提交回复
热议问题