【问题标题】:Add content-disposition metadata when uploading to s3 using the cli使用 cli 上传到 s3 时添加 content-disposition 元数据
【发布时间】:2019-11-22 00:32:15
【问题描述】:

如何使用 AWS CLI 上传文件并为 Content-Disposition 响应标头指定值?通过控制台,可以通过将其添加为元数据来创建此标头,但 CLI 命令将允许它成为 CI 管道的一部分。

Content-Disposition 响应头:https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition

【问题讨论】:

    标签: amazon-web-services amazon-s3 http-headers aws-cli


    【解决方案1】:

    aws cli 命令cp 有一个可选参数--content-disposition,使这成为可能。 --content-dispostion 可以设置为attachmentinline

    aws s3 cp <src> <dest> --content-disposition attachment
    

    这适用于在上传元数据时设置元数据,但如果您稍后将此文件复制到 s3 中的不同路径,元数据将不会保留。要让它持续存在,您需要在上传时使用 --metadata-directive REPLACE 参数显式设置它。我使用的最后一个命令是:

    aws s3 cp <src> <dest> --metadata-directive REPLACE --content-disposition attachment
    

    aws s3 cp 文档:https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html

    【讨论】:

      猜你喜欢
      • 2015-06-21
      • 2012-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多