you can refer on how to Create Google Cloud Storage Bucket Using UI/console In Google Cloud Platform here
Using gsutil – command line (Cloud Shell) Click on above icon and you can see shell similar to this opening up.
Creating Google bucket using CLI:
To set your Cloud Platform project in this session use “gcloud config set project [PROJECT_ID]”
· gcloud config set project bigquery-demo1-326311
· gsutil –help
· To list all in console just use “ls”.
· Create a bucket
o gsutil mb gs://demo02-bucket
If bucket name already exists we will get error code 409. 409 A Cloud Storage bucket named ‘demo02-bucket’ already exists. Try another name. Bucket names must be globally unique across all Google Cloud projects, including those outside of your organization.
Upload file from local to GCP cloud storage:
· Click on Upload button and you can choose file to upload into GCP. Here I selected health.json and patient.json file into Cloud storage from cloudshell.
The same how it looks in GCP UI.
· Then to load the uploaded file into bucket created, follow below commands. To give global access to a file in a bucket
o gsutil acl ch -u ALLUsers:R gs://demo02-bucket/patient.json
· Copy data from one bucket to another bucket. Error: AccessDeniedException: 403 Object ‘demo01-bucket/health.json’ is subject to bucket’s retention policy and cannot be deleted, overwritten or archived until 2021-09-30T02:01:14.331731-07:00
o gsutil cp gs://demo01-bucket/* gs://demo02-bucket
NOTE: If retention policy is present in bucket, you are likely to face this error “Error: 403, subject to bucket’s retention policy and cannot be deleted, overwritten or archived until 2021-09-30T02:01:14.33”
· How to enable version in gsutil
o gsutil versioning get gs://demo01-bucket
NOTE: response: gs://demo01-bucket: Suspended (BadRequestException: 400 Bucket’s Versioning cannot be set for Bucket ‘demo01-bucket’ that has retention policy.)
· Enabling the versioning in demo01-bucket
o gsutil versioning set on gs://demo01-bucket
· To list all the files in the bucket
o gsutil ls gs://demo02-bucket
· To list all hidden files in the bucket
o gsutil ls -a gs://demo02-bucket
· After enabling version in gs://demo02-bucket, Try running the command
o gsutil cp gs://demo01-bucket/* gs://demo02-bucket
· To list all the files in the bucket
o gsutil ls -a gs://demo02-bucket