Working with storages

The following code can be used to create storage buckets:

gsutil mb -p [PROJECT_NAME] -c [STORAGE_CLASS] -l [BUCKET_LOCATION] gs://[BUCKET_NAME]/

Listing buckets in a project can be done using this code:

gsutil ls

We will use the following code to get bucket information or listing a buckets contents:

gsutil ls -r gs://[BUCKET_NAME]/**

The following code is used to copy files from your old bucket to your new bucket:

gsutil cp -r gs://[SOURCE_BUCKET]/* gs://[DESTINATION_BUCKET]

We can use the following code to delete the files from the bucket:

gsutil rm -r gs://[BUCKET_NAME]/**

We will use this code to delete the bucket and the files in the bucket:

gsutil ls -r gs://[BUCKET_NAME]

Get Cloud Analytics with Google Cloud Platform now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.