Change Content-Disposition of existing S3 object

前端 未结 2 641
一个人的身影
一个人的身影 2020-12-09 19:55

In S3 REST API I am adding metadata to an existing object by using the PUT (Copy) command and copying a key to the same location with \'x-amz-metadata-directive\' = \'

相关标签:
2条回答
  • 2020-12-09 20:37

    here: this uses the cli to set the content-disposition header on all files in a path inside a bucket (and also sets them as public):

    aws s3 ls s3://mybucket/brand_img/ios/|awk {'print $4'} > objects.txt
    
     while read line; do aws s3api copy-object --bucket mybucket  \
    --copy-source /mybucket/brand_img/ios/$line --key brand_img/ios/$line \
    --metadata-directive REPLACE --metadata Content-Disposition=$line --acl public-read; done < objects.txt
    
    0 讨论(0)
  • 2020-12-09 20:38

    Edited for clarity:

    Content-Disposition must be set explicitly and not included as x-amz-meta-Content-Disposition. All metadata header names must start with "x-amz-meta-" and be all lowercase.

    Thanks to @Eyal for clarifying.

    Original:

    >SOLVED:
    >
    >The Doco at http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?RESTAuthentication.html
    >
    >seems to be wrong it says:
    >
    >Notice how the 'x-amz-' headers are sorted, white-space trimmed, converted tolowercase, and multiple headers with the same name have been joined using a comma toseparate values.
    >
    >Note how only the Content-Type and Content-MD5HTTPentity headers appear in the StringToSign .The otherContent-* entity headers do not.
    However Content-Disposition must be set specifically and not included as : x-amz-meta-Content-Disposition
    >
    >It now works fine.
    
    0 讨论(0)
提交回复
热议问题