Created
April 22, 2020 08:37
-
-
Save fonylew/480ab35656572c5341510b59785ac2e8 to your computer and use it in GitHub Desktop.
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
# Create a new Bucket | |
gsutil mb gs://[BUCKET] | |
# List files in bucket | |
gsutil ls gs://[BUCKET] | |
# Check bucket usage (du: disk usage) | |
gsutil du -sh gs://[BUCKET] | |
# Copy (upload) file to bucket | |
gsutil cp [File] gs://[BUCKET] | |
# > no need to create directory | |
gsutil cp [File] gs://[BUCKET]/path/to/file | |
# > copy (upload) directory | |
gsutil cp -r [Folder] gs://[BUCKET] | |
# > enable multiprocessing | |
gsutil -m cp -r [Folder] gs://[BUCKET] | |
# > copy (download) file | |
gsutil cp gs://[BUCKET]/path/to/file [File] | |
# > copy (download) directory to current local directory | |
gsutil -m cp -r gs://[BUCKET]/path . | |
# > copy (download) txt files to current local directory | |
gsutil -m cp gs://[BUCKET]/*.txt . | |
# Move or rename object | |
gsutil mv gs://[BUCKET]/path/to/old_name gs://[BUCKET]/path/to/new_name | |
# Remove file or directory | |
# > remove file | |
gsutil rm gs://[BUCKET]/path/to/file | |
# > remove directory | |
gsutil rm -r gs://[BUCKET]/path/to/directory | |
# Doc: https://cloud.google.com/storage/docs/how-to |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Python uploading example: https://cloud.google.com/storage/docs/uploading-objects#storage-upload-object-python
It requires a service account if it is not run on Google Cloud environment where default service account is supplied,
or
Set up Application Default Credentials for local developement: https://cloud.google.com/sdk/gcloud/reference/auth/application-default/login