代码之家  ›  专栏  ›  技术社区  ›  Tschareck

使用具有适当内容类型的aws cli复制到s3

  •  0
  • Tschareck  · 技术社区  · 6 年前

    我正在将静态angularjs网页部署到s3 bucket。我使用jenkins,使用aws cli通过shell复制文件。groovy中的特定命令如下:

    // after build, files are located in frontend/target/myfrontend/
    sh 'aws s3 cp frontend/target/myfrontend/ $FrontendAddress --recursive'
    

    我有SVG图形 /resources 文件夹。图像在内部显示不正确 img 标记,因为它的内容类型默认设置为 binary/octet-stream . 应该是 image/svg+xml 相反。

    如何复制svg文件 aws s3 cp 命令,并设置正确的内容类型?

    1 回复  |  直到 6 年前
        1
  •  2
  •   Tschareck    6 年前

    更改*.svg文件内容类型的命令是:

    aws s3 cp --content-type image/svg+xml --acl public-read $FrontendAddress/resources/ $FrontendAddress/resources/ --metadata-directive REPLACE --exclude "*" --include "*.svg" --recursive
    
        2
  •  0
  •   sharad-garg    5 年前
    aws s3 sync _site/ s3://BUCKET --delete --exclude '*.svg'
    aws s3 sync _site/ s3://BUCKET --delete --exclude '*' --include '*.svg' --content-type 'image/svg+xml'