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?
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
aws s3 sync _site/ s3://BUCKET --delete --exclude '*.svg'
aws s3 sync _site/ s3://BUCKET --delete --exclude '*' --include '*.svg' --content-type 'image/svg+xml'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With