Skip to content
Snippets Groups Projects
Commit 555c7520 authored by Athanasios Karmas's avatar Athanasios Karmas
Browse files

Add new file to upload to Swift S3 API

parent 28dcdc40
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
# about the file
file_to_upload=$1
bucket=$2
filepath="/${bucket}/${file_to_upload}"
# metadata
contentType="application/x-compressed-tar"
dateValue=`date -R`
signature_string="PUT\n\n${contentType}\n${dateValue}\n${filepath}"
#s3 keys
s3_access_key=$3
s3_secret_key=$4
#prepare signature hash to be sent in Authorization header
signature_hash=`echo -en ${signature_string} | openssl sha1 -hmac ${s3_secret_key} -binary | base64`
# actual curl command to do PUT operation on s3
curl -X PUT -T "${file_to_upload}" \
-H "Host: object.cscs.ch:443/${bucket}" \
-H "Date: ${dateValue}" \
-H "Content-Type: ${contentType}" \
-H "Authorization: AWS ${s3_access_key}:${signature_hash}" \
https://object.cscs.ch/${bucket}/${file_to_upload}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment