Created
January 25, 2024 19:04
-
-
Save jclosure/4f6f25c607a4c91b1536be2cdc5c808a to your computer and use it in GitHub Desktop.
Download S3 objects with only curl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Example: | |
# for minio: in k9s, forward ports 9000 and 9001 to localhost | |
# ./curl_object_downloader.sh localhost:9000 mykey_id mykey_secret \ | |
# mybucket mypath/myobj.bin ./myobj.bin | |
# User Minio Vars | |
URL=$1 | |
USERNAME=$2 | |
PASSWORD=$3 | |
BUCKET=$4 | |
MINIO_PATH="/${BUCKET}/$5" | |
OUT_FILE=$6 | |
# Static Vars | |
DATE=$(date -R --utc) | |
CONTENT_TYPE='application/zstd' | |
SIG_STRING="GET\n\n${CONTENT_TYPE}\n${DATE}\n${MINIO_PATH}" | |
SIGNATURE=`echo -en ${SIG_STRING} | openssl sha1 -hmac ${PASSWORD} -binary | base64` | |
curl -o "${OUT_FILE}" \ | |
-H "Host: $URL" \ | |
-H "Date: ${DATE}" \ | |
-H "Content-Type: ${CONTENT_TYPE}" \ | |
-H "Authorization: AWS ${USERNAME}:${SIGNATURE}" \ | |
http://$URL${MINIO_PATH} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment