This page contains code samples for Cloud Storage. To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.
View in documentation
Create a Bucket to store Terraform state
This sample creates a Bucket with Object Versioning enabled in the US multi-region to store Terraform state.
View in documentation
Create a bucket with options
Create a Cloud Storage bucket with storage class and location parameters.
View in documentation
Create a Cloud Storage Bucket
Create a Cloud Storage Bucket with main page and not found page settings.
View in documentation
Create a Pub/Sub notification on a Bucket
This sample creates a Pub/Sub notification configuration on a Bucket that sends notifications for all supported events.
View in documentation
View in documentation
View in documentation
View in documentation
Get a bucket's metadata
Retrieve metadata from a Cloud Storage bucket.
View in documentation
Get an object's KMS key name
Get a resource's KMS key name that's used to encrypt an object.
View in documentation
Get an object's metadata
Retrieve metadata of an object in a Cloud Storage bucket.
View in documentation
View in documentation
List buckets using Amazon S3 SDKs
List Cloud Storage buckets that use Amazon Simple Storage Service (Amazon S3) SDKs by using the Cloud Storage XML API with HMAC credentials.
View in documentation
List files in a paginated manner
List objects in a bucket with no autopagination, showing how to move to the next set of objects.
List the objects in a bucket
List all the objects in a Cloud Storage bucket.
View in documentation
Make a Bucket public
This sample makes all objects in a Bucket readable to everyone on the public internet.
View in documentation
Make a bucket public
Make a bucket public by using a bucket-level IAM policy.
View in documentation
Make static website Bucket public
This samples make all objects in the static website Bucket readable to anyone on the public internet.
View in documentation
Move an object
Moving an object in Cloud Storage consists of two operations. First, you copy the object to a destination bucket and rename the moved object. Next, you delete the original object. Delete an object only when the old and new destinations are not equal.
View in documentation