Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy to S3 with AWS CLI with proper content type

I'm deploying static AngularJS webpage to S3 bucket. I use Jenkins, copy file over Shell with AWS CLI. The specific command in Groovy looks like this:

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

I have SVG graphics in /resources folder. That image is not displayed correctly inside img tag, because it has content-type set by default to binary/octet-stream. It should be image/svg+xml instead.

How to copy my SVG files with aws s3 cp command, and set correct content type?

like image 329
Tschareck Avatar asked Jun 14 '18 11:06

Tschareck


2 Answers

The command to change content type for *.svg files is:

aws s3 cp --content-type image/svg+xml --acl public-read $FrontendAddress/resources/ $FrontendAddress/resources/ --metadata-directive REPLACE --exclude "*" --include "*.svg" --recursive
like image 164
Tschareck Avatar answered Nov 20 '22 13:11

Tschareck


aws s3 sync _site/ s3://BUCKET --delete --exclude '*.svg'
aws s3 sync _site/ s3://BUCKET --delete --exclude '*' --include '*.svg' --content-type 'image/svg+xml'
like image 36
sharad-garg Avatar answered Nov 20 '22 13:11

sharad-garg