Created
October 30, 2014 15:11
-
-
Save micheleorsi/023242efc506b27f4074 to your computer and use it in GitHub Desktop.
upload file to Google Cloud Storage, set it public and set cache
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 | |
# Check args | |
if [ $# \< 2 ]; then | |
echo "Usage: $(basename $0 $1) <file> <cache-millisec>"; | |
exit 1; | |
fi | |
#file name | |
fileName=""; | |
if [ "$1" != "" ]; then | |
fileName="$1"; | |
fi | |
#file name | |
cache=""; | |
if [ "$2" != "" ]; then | |
cache="$2"; | |
fi | |
bucketName = 'mybucket' | |
gsutil cp $fileName gs://$bucketName/$fileName | |
gsutil setmeta -h "Cache-Control:public, max-age=$cache" gs://$bucketName/$fileName | |
gsutil acl set public-read gs://$bucketName/$fileName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment