Todas las muestras de código de Cloud Storage

Activate an HMAC key

Updates the state of an HMAC key to "Active."

Add a default ACL to a bucket

Add a default access control list (ACL) to a Cloud Storage bucket.

Add a label to a bucket

Add a label to a Cloud Storage bucket.

View in documentation

Add an IAM member

Add a member to the bucket IAM policy.

View in documentation

Add an owner ACL to an object

Add an owner access control list (ACL) to an object in a Cloud Storage bucket.

Add an owner to a bucket

Add owner access control to a Cloud Storage bucket.

Add conditional role binding

An example of how to set a startsWith condition with the client libraries.

View in documentation

Amazon S3 SDK: List objects

Shows an example of listing objects to help developers overcome an issue with interoperability until it's fixed.

Change the default storage class of a bucket

Update the storage class of a Cloud Storage bucket.

Compose multiple objects

Compose multiple objects into a single object in a Cloud Storage bucket.

View in documentation

Configure CORS for a bucket

Add a CORS configuration to a Cloud Storage bucket.

Convert CSEK to CMEK

Sample converts CSEK to CMEK.

Copy an archived object

Copy an archived generation of an object in a Cloud Storage bucket.

View in documentation

Copy an object between buckets

Copy an object from one Cloud Storage bucket to another.

Create a bucket with options

Create a Cloud Storage bucket with storage class and location parameters.

Create a GET-signed URL for an object using Cloud Storage libraries (V4)

Generate a V4-signed URL to download an object.

Create a new Pub/Sub notification

Add a Pub/Sub notification to a Cloud Storage bucket.

Create a PUT-signed URL using Cloud Storage libraries (V4)

Provides a sample of how to generate a PUT-signed URL that is used to upload an object.

Create a service account HMAC key

Create a service account HMAC key.

Deactivate a service account HMAC key

Updates the state of a service account HMAC key to "Inactive."

Delete a bucket

Demonstrates deleting a Cloud Storage bucket.

Delete a Pub/Sub notification

Delete a Pub/Sub notification from a Cloud Storage storage bucket.

Delete an archived generation of an object

Delete an archived generation of an object in a Cloud Storage bucket.

View in documentation

Delete an HMAC key

Delete an HMAC key based on the access ID.

Delete an IAM member

Delete a member from the IAM policy for a Cloud Storage bucket.

View in documentation

Delete an object

Delete an object in a Cloud Storage bucket.

View in documentation

Disable a default event-based hold on a bucket

Provides an example of how to disable a bucket's default event-based hold.

View in documentation

Disable a lifecycle policy

Disable lifecycle management for a Cloud Storage bucket.

View in documentation

Disable object versioning for a bucket

Disable object versioning for a Cloud Storage bucket.

View in documentation

Disable the requester pays status for a bucket

Disable the requester pays status for a Cloud Storage bucket.

View in documentation

Disable uniform bucket-level access

Disable uniform bucket-level access.

View in documentation

Download a CSEK-encrypted object

Download a CSEK-encrypted object.

Download a public object without credentials

Download an object from a public data set object.

View in documentation

Download an object

Download an object from a Cloud Storage bucket.

View in documentation

Enable a default event-based hold

Provides an example of how to enable a default event-based hold.

View in documentation

Enable lifecycle management for a bucket

Enable lifecycle management for a Cloud Storage bucket.

View in documentation

Enable object versioning for a bucket

Enable object versioning for a Cloud Storage bucket.

View in documentation

Enable Requester Pays for a bucket

Enable the Requester Pays status for a Cloud Storage bucket.

View in documentation

Enable uniform bucket-level access

Enable uniform bucket-level access.

View in documentation

Generate an encryption key

Generate an encryption key.

Get a bucket's ACL

View the access control list (ACL) for a Cloud Storage bucket.

Get a bucket's ACL that's filtered by user

View the access control list (ACL) for a Cloud Storage bucket that's filtered by user.

Get a bucket's default KMS key

Get a bucket's default KMS key.

Get a lifecycle policy for a bucket

View the lifecycle configuration of a Cloud Storage bucket.

View in documentation

Get a Pub/Sub notification

Provides an example of how to get Pub/Sub notification metadata.

Get a retention policy

Provides an example of how to get a bucket's retention policy.

View in documentation

Get a service account

Get a Cloud Storage service account using projects.GetServiceAccount (). This is used by Pub/Sub notifications and CMEK KMS keys.

Get an HMAC key

Get an HMAC key with its access ID.

Get an object ACL that's filtered by user

View the access control list (ACL) for an object in a Cloud Storage bucket that's filtered by user.

Get an object's ACL

View the access control list (ACL) for an object in a Cloud Storage bucket.

Get an object's KMS key name

Get a resource's KMS key name that's used to encrypt an object.

Get an object's metadata

Retrieve metadata of an object in a Cloud Storage bucket.

Get IAM members

Get the members from an IAM policy for a Cloud Storage bucket.

View in documentation

Get the Requester Pays status on a bucket

Get the Requester Pays status for a Cloud Storage bucket.

View in documentation

Get the state of a default event-based hold

Example of how to get the state of a default event-based hold.

View in documentation

Get uniform bucket-level access

Get uniform bucket-level access.

View in documentation

List archived generations

List archived generations for an object in a Cloud Storage bucket.

View in documentation

List bucket labels

Retrieve the labels for a Cloud Storage bucket.

View in documentation

List buckets

List the Cloud Storage buckets in a project.

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.

List Pub/Sub notifications

List the Pub/Sub notifications set up for a Cloud Storage storage bucket.

List the objects in a bucket

List all the objects in a Cloud Storage bucket.

View in documentation

List the objects in a bucket using a prefix filter

List the objects in a Cloud Storage bucket using a prefix.

View in documentation

Lock a bucket's retention policy

Provides an example of how to lock a bucket's retention policy.

View in documentation

Make a bucket public

Make a bucket public by using a bucket-level IAM policy.

Make an object public

Make an object in a Cloud Storage bucket publicly accessible.

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.

Print the website configuration for a Cloud Storage bucket.

Release a temporary hold on an object

Shows an example of how to release a temporary hold on an object.

View in documentation

Release an event-based hold on an object

Release an event-based hold on an object.

View in documentation

Remove a bucket label

Remove a label from a Cloud Storage bucket.

View in documentation

Remove a default ACL from a bucket

Remove a default access control list (ACL) for a Cloud Storage bucket.

Remove an owner from a bucket

Remove owner access control to a Cloud Storage bucket.

Remove owner access to an object

Remove owner access to an object in a Cloud Storage bucket.

Remove retention policy

Shows an example of how to remove a retention policy on a bucket. The bucket retention policy must be unlocked to successfully remove a policy.

View in documentation

Remove the default KMS key name

Remove the default KMS key name.

Requester Pays: Download an object

Download a file using the specified project as the requester.

View in documentation

Rotate an encryption key

Rotate an encryption key.

Set a default KMS key for a bucket

Sets a default CMEK for a bucket.

Set a retention policy

An example of how to set a retention policy on a bucket.

View in documentation

Set a temporary hold on an object

An example of how to set a temporary hold on an object.

View in documentation

Set an event-based hold on an object

An example of how to set an event-based hold on an object.

View in documentation

Set an object's metadata

Set the metadata for an object in a Cloud Storage bucket.

View in documentation

Set the website configuration on a bucket

Set the static website configuration for a Cloud Storage bucket.

Update the object storage class

Rewrite and update the object storage class of a Cloud Storage object.

View in documentation

Upload an object by using CSEK

Upload an object by using customer-supplied encryption keys (CSEK).

Upload an object with a specified KMS key

Upload an object with a specified CMEK KMS key.