Skip to content

Instantly share code, notes, and snippets.

@micheleorsi
Created October 30, 2014 15:11
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 micheleorsi/023242efc506b27f4074 to your computer and use it in GitHub Desktop.
Save micheleorsi/023242efc506b27f4074 to your computer and use it in GitHub Desktop.
upload file to Google Cloud Storage, set it public and set cache
#!/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