gcloud CLI init:
gcloud initexport bucket name (it must be unique)
export BUCKETNAME=my-awesome-bucketCreate bucket
gcloud storage buckets create gs://$BUCKETNAME/ --uniform-bucket-level-accessUpload an object into your bucket:
gcloud storage cp Desktop/kitten.png gs://$BUCKETNAMEDownload the object from your bucket
gcloud storage cp gs://$BUCKETNAME/kitten.png Desktop/kitten2.pngCopy the object to a folder in the bucket
gcloud storage cp gs://$BUCKETNAME/kitten.png gs://$BUCKETNAME/just-a-folder/kitten3.pngList contents of a bucket or folder
gcloud storage ls gs://$BUCKETNAMEList details for an object
gcloud storage ls gs://$BUCKETNAME/kitten.png --longMake the objects publicly accessible
- Use the
gcloud storage buckets add-iam-policy-bindingcommand to grant all users permission to read the images stored in your bucket:
gcloud storage buckets add-iam-policy-binding gs://$BUCKETNAME --member=allUsers --role=roles/storage.objectViewer- To remove this access, use the command:
gcloud storage buckets remove-iam-policy-binding gs://$BUCKETNAME --member=allUsers --role=roles/storage.objectViewerGive someone access to your bucket
Use the gcloud storage buckets add-iam-policy-binding command to give a specific email address permission to add objects to your bucket:
gcloud storage buckets add-iam-policy-binding gs://$BUCKETNAME --member=user:jane@gmail.com --role=roles/storage.objectCreatorTo remove this permission, use the command:
gcloud storage buckets remove-iam-policy-binding gs://$BUCKETNAME --member=user:jane@gmail.com --role=roles/storage.objectCreator
Delete an object
Use the gcloud storage rm command to delete one of your images:
gcloud storage rm gs://$BUCKETNAME/kitten.pngClean up
Use the gcloud storage rm command with the --recursive flag to delete the bucket and anything inside of it:
gcloud storage rm gs://$BUCKETNAME --recursive