s3/s3upload.sh hinzugefügt

This commit is contained in:
Phil 2023-08-22 20:36:08 +02:00
parent 07bb9a8f1a
commit 76fe832e66

25
s3/s3upload.sh Normal file
View file

@ -0,0 +1,25 @@
#!/bin/bash
# S3 upload script for CI-Builds
# ./s3upload.sh bucket file.zip | Warning if file is in folder folder gets created on path!
s3_bucket=$1
s3_file=$2
# Needed environment vars:
# s3_host
# s3_key
# s3_secret
resource="/${s3_bucket}/${s3_file}"
content_type="application/octet-stream"
date=`date -R`
_signature="PUT\n\n${content_type}\n${date}\n${resource}"
signature=`echo -en ${_signature} | openssl sha1 -hmac ${s3_secret} -binary | base64`
curl -X PUT -T "${s3_file}" \
-H "Host: ${s3_host}" \
-H "Date: ${date}" \
-H "Content-Type: ${content_type}" \
-H "Authorization: AWS ${s3_key}:${signature}" \
https://${s3_host}${resource}