Skip to content

Instantly share code, notes, and snippets.

@amit-gshe
Created August 12, 2020 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amit-gshe/06b665a1ddd8cc940206db58774f4da8 to your computer and use it in GitHub Desktop.
Save amit-gshe/06b665a1ddd8cc940206db58774f4da8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
AccessKeyId=test
Secret=test
file_array=()
for dir in $*; do
for file in `find $dir -type f`; do
# echo $file
file_array+=(h5devcdn.cc.lerjin.com/$file)
done
done
files_param=$( IFS='|' ; echo "${file_array[*]}" )
ObjectPath="${files_param//|/\n}"
params=(
AccessKeyId=$AccessKeyId
Format=JSON
ObjectPath=$ObjectPath
SignatureMethod=HMAC-SHA1
SignatureNonce=`date +%s`
SignatureVersion=1.0
Timestamp=`date -u +%Y-%m-%dT%H:%M:%SZ`
)
params_str=$(IFS='&' ; echo "${params[*]}")
sign_str="$Secret&POST&%2F&$params_str"
Signature=`echo -n $sign_str | openssl dgst -sha1 -hmac "$Secret&" -binary | base64`
params+=(Signature=$Signature)
echo "http --form https://cdn.aliyuncs.com ${params[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment