# 2009 Copyright Yejun Yang (yejunx AT gmail DOT com) # Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License. # http://creativecommons.org/licenses/by-nc-sa/3.0/us/ API_KEY= USER= CONTAINER= if [[ -n $1 ]]; then LOC=$1 else LOC="*" fi eval $(curl -s -X "GET" -D - \ -H "X-Auth-Key:$API_KEY" \ -H "X-Auth-User:$USER" \ https://api.mosso.com/auth | gawk '$1=="X-Storage-Token:" { sub(/\r/,"",$2);printf("TOKEN=\"%s\"\n",$2); } $1=="X-Storage-Url:" { sub(/\r/,"",$2);printf("URL=\"%s\"\n",$2) } $1=="X-CDN-Management-Url:" { sub(/\r/,"",$2);printf("CDN=\"%s\"\n",$2) }') function put { echo -n "Uploading $1 .... " curl -s -X "PUT" -T "$1" \ -H "X-Auth-Token: $TOKEN" \ -H "Content-Type: $3" \ $URL/$CONTAINER/$2 && echo "done." } curl -s -X "PUT" \ -H "X-Auth-Token: $TOKEN" \ $URL/$CONTAINER for f in $(find $LOC -type f -readable -name \*.js); do put $f $f application/x-javascript done for f in $(find $LOC -type f -readable -name \*.css); do put $f $f text/css done for f in $(find $LOC -type f -readable \( -name \*.jpeg -o -name \*.jpg \) ); do put $f $f image/jpeg done for f in $(find $LOC -type f -readable -name \*.gif); do put $f $f image/gif done for f in $(find $LOC -type f -readable -name \*.png); do put $f $f image/png done curl -s -X "PUT" -D - \ -H "X-Auth-Token: $TOKEN" \ $CDN/$CONTAINER