google-cloud-storage 3.4.1


pip install google-cloud-storage

  Latest version

Released: Oct 08, 2025

Project Links

Meta
Author: Google LLC
Requires Python: >=3.7

Classifiers

Development Status
  • 5 - Production/Stable

Intended Audience
  • Developers

License
  • OSI Approved :: Apache Software License

Programming Language
  • Python
  • Python :: 3
  • Python :: 3.7
  • Python :: 3.8
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13

Operating System
  • OS Independent

Topic
  • Internet

stable pypi versions

Google Cloud Storage is a managed service for storing unstructured data. Cloud Storage allows world-wide storage and retrieval of any amount of data at any time. You can use Cloud Storage for a range of scenarios including serving website content, storing data for archival and disaster recovery, or distributing large data objects to users via direct download.

NOTE: 3.0 Major Version Notes are available. Feedback welcome.

A comprehensive list of changes in each version may be found in the CHANGELOG.

Certain control plane and long-running operations for Cloud Storage (including Folder and Managed Folder operations) are supported via the Storage Control Client. The Storage Control API creates one space to perform metadata-specific, control plane, and long-running operations apart from the Storage API.

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Quick Start

In order to use this library, you first need to go through the following steps. A step-by-step guide may also be found in Get Started with Client Libraries.

  1. Select or create a Cloud Platform project.

  2. Enable billing for your project.

  3. Enable the Google Cloud Storage API.

  4. Setup Authentication.

Installation

Install this library in a virtual environment using venv. venv is a tool that creates isolated Python environments. These isolated environments can have separate versions of Python packages, which allows you to isolate one project’s dependencies from the dependencies of other projects.

With venv, it’s possible to install this library without needing system install permissions, and without clashing with the installed system dependencies.

Code samples and snippets

Code samples and snippets live in the samples/ folder.

Supported Python Versions

Our client libraries are compatible with all current active and maintenance versions of Python.

Python >= 3.7

Unsupported Python Versions

Python <= 3.6

If you are using an end-of-life version of Python, we recommend that you update as soon as possible to an actively supported version.

Mac/Linux

python3 -m venv <your-env>
source <your-env>/bin/activate
pip install google-cloud-storage

Windows

py -m venv <your-env>
.\<your-env>\Scripts\activate
pip install google-cloud-storage

Example Usage

# Imports the Google Cloud client library
from google.cloud import storage

# Instantiates a client
storage_client = storage.Client()

# The name for the new bucket
bucket_name = "my-new-bucket"

# Creates the new bucket
bucket = storage_client.create_bucket(bucket_name)

print(f"Bucket {bucket.name} created.")

Tracing With OpenTelemetry

This is a PREVIEW FEATURE: Coverage and functionality are still in development and subject to change.

This library can be configured to use OpenTelemetry to generate traces on calls to Google Cloud Storage. For information on the benefits and utility of tracing, read the Cloud Trace Overview.

To enable OpenTelemetry tracing in the Cloud Storage client, first install OpenTelemetry:

pip install google-cloud-storage[tracing]

Set the ENABLE_GCS_PYTHON_CLIENT_OTEL_TRACES environment variable to selectively opt-in tracing for the Cloud Storage client:

export ENABLE_GCS_PYTHON_CLIENT_OTEL_TRACES=True

You will also need to tell OpenTelemetry which exporter to use. An example to export traces to Google Cloud Trace can be found below.

# Install the Google Cloud Trace exporter and propagator, however you can use any exporter of your choice.
pip install opentelemetry-exporter-gcp-trace opentelemetry-propagator-gcp

# [Optional] Install the OpenTelemetry Requests Instrumentation to trace the underlying HTTP requests.
pip install opentelemetry-instrumentation-requests
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter

tracer_provider = TracerProvider()
tracer_provider.add_span_processor(BatchSpanProcessor(CloudTraceSpanExporter()))
trace.set_tracer_provider(tracer_provider)

# Optional yet recommended to instrument the requests HTTP library
from opentelemetry.instrumentation.requests import RequestsInstrumentor
RequestsInstrumentor().instrument(tracer_provider=tracer_provider)

In this example, tracing data will be published to the Google Cloud Trace console. Tracing is most effective when many libraries are instrumented to provide insight over the entire lifespan of a request. For a list of libraries that can be instrumented, refer to the OpenTelemetry Registry.

3.0 Major Version Notes

Feedback Welcome

If you experience that backwards compatibility for your application is broken with this major version release, please let us know through the Github issues system. While some breaks of backwards compatibility may be unavoidable due to new features in the major version release, we will do our best to minimize them. Thank you.

Exception Handling

In Python Storage 3.0, the dependency google-resumable-media was integrated. The google-resumable-media dependency included exceptions google.resumable_media.common.InvalidResponse and google.resumable_media.common.DataCorruption, which were often imported directly in user application code. The replacements for these exceptions are google.cloud.storage.exceptions.InvalidResponse and google.cloud.storage.exceptions.DataCorruption. Please update application code to import and use these exceptions instead.

For backwards compatibility, if google-resumable-media is installed, the new exceptions will be defined as subclasses of the old exceptions, so applications should continue to work without modification. This backwards compatibility feature may be removed in a future major version update.

Some users may be using the original exception classes from the google-resumable-media library without explicitly installing that library. So as not to break user applications following this pattern, google-resumable-media is still in the list of dependencies in this package’s setup.py file. Applications which do not import directly from google-resumable-media can safely disregard this dependency. This backwards compatibility feature will be removed in a future major version update. Please migrate to using the google.cloud.storage.exceptions classes as above.

Checksum Defaults

In Python Storage 3.0, uploads and downloads now have a default of “auto” where applicable. “Auto” will use crc32c checksums, except for unusual cases where the fast (C extension) crc32c implementation is not available, in which case it will use md5 instead. Before Python Storage 3.0, the default was md5 for most downloads and None for most uploads. Note that ranged downloads (“start” or “end” set) still do not support any checksumming, and some features in transfer_manager.py still support crc32c only.

Note: The method Blob.upload_from_file() requires a file in bytes mode, but when checksum is set to None, as was the previous default, would not throw an error if passed a file in string mode under some circumstances. With the new defaults, it will now raise a TypeError. Please use a file opened in bytes reading mode as required.

Miscellaneous

  • The BlobWriter class now attempts to terminate an ongoing resumable upload if the writer exits with an exception.

  • Retry behavior is now identical between media operations (uploads and downloads) and other operations, and custom predicates are now supported for media operations as well.

  • Blob.download_as_filename() will now delete the empty file if it results in a google.cloud.exceptions.NotFound exception (HTTP 404).

  • Previously, object upload, metadata update, and delete methods had retries disabled by default unless the generation or metageneration was specified in the request. This has now changed so that retries are enabled by default.

Next Steps

3.4.1 Oct 08, 2025
3.4.0 Sep 15, 2025
3.3.1 Sep 01, 2025
3.3.0 Aug 12, 2025
3.2.0 Jul 07, 2025
3.1.1 Jun 18, 2025
3.1.0 Feb 28, 2025
3.0.0 Jan 29, 2025
3.0.0rc1 Dec 12, 2024
2.19.0 Dec 05, 2024
2.18.2 Aug 08, 2024
2.18.1 Aug 07, 2024
2.18.0 Jul 22, 2024
2.17.0 Jun 10, 2024
2.16.0 Mar 18, 2024
2.15.0 Mar 04, 2024
2.14.0 Dec 12, 2023
2.14.0rc1 Dec 07, 2023
2.13.0 Oct 31, 2023
2.12.0 Oct 12, 2023
2.11.0 Sep 19, 2023
2.10.0 Jun 26, 2023
2.9.0 May 04, 2023
2.8.0 Mar 29, 2023
2.7.0 Dec 07, 2022
2.6.0 Nov 07, 2022
2.5.0 Aug 03, 2022
2.4.0 Jun 08, 2022
2.3.0 Apr 13, 2022
2.2.1 Mar 15, 2022
2.2.0 Mar 14, 2022
2.1.0 Jan 19, 2022
2.0.0 Jan 12, 2022
1.44.0 Jan 05, 2022
1.43.0 Nov 17, 2021
1.42.3 Sep 30, 2021
1.42.2 Sep 16, 2021
1.42.1 Sep 08, 2021
1.42.0 Aug 11, 2021
1.41.1 Jul 20, 2021
1.41.0 Jul 13, 2021
1.40.0 Jun 30, 2021
1.39.0 Jun 22, 2021
1.38.0 Apr 26, 2021
1.37.1 Apr 05, 2021
1.37.0 Mar 25, 2021
1.36.2 Mar 11, 2021
1.36.1 Feb 23, 2021
1.36.0 Feb 10, 2021
1.35.1 Feb 02, 2021
1.35.0 Dec 14, 2020
1.34.0 Dec 11, 2020
1.33.0 Nov 16, 2020
1.32.0 Oct 19, 2020
1.31.2 Sep 23, 2020
1.31.1 Sep 21, 2020
1.31.0 Aug 26, 2020
1.30.0 Jul 24, 2020
1.29.0 Jun 11, 2020
1.28.1 May 04, 2020
1.28.0 Apr 22, 2020
1.27.0 Apr 02, 2020
1.26.0 Feb 12, 2020
1.25.0 Jan 16, 2020
1.24.1 Jan 02, 2020
1.24.0 Jan 02, 2020
1.23.0 Nov 13, 2019
1.22.0 Nov 05, 2019
1.21.0 Oct 29, 2019
1.20.0 Sep 26, 2019
1.19.1 Sep 17, 2019
1.19.0 Aug 28, 2019
1.18.1 Sep 17, 2019
1.18.0 Aug 07, 2019
1.17.1 Sep 17, 2019
1.17.0 Jul 24, 2019
1.16.2 Sep 17, 2019
1.16.1 Jun 04, 2019
1.16.0 May 17, 2019
1.15.2 Sep 17, 2019
1.15.1 May 15, 2019
1.15.0 Apr 17, 2019
1.14.1 Sep 17, 2019
1.14.0 Feb 06, 2019
1.13.3 Sep 17, 2019
1.13.2 Dec 18, 2018
1.13.1 Dec 11, 2018
1.13.0 Oct 01, 2018
1.12.1 Sep 17, 2019
1.12.0 Sep 12, 2018
1.11.1 Sep 17, 2019
1.11.0 Aug 29, 2018
1.10.0 May 18, 2018
1.9.0 May 04, 2018
1.8.0 Feb 28, 2018
1.7.0 Jan 16, 2018
1.6.0 Oct 31, 2017
1.5.0 Oct 18, 2017
1.4.0 Aug 24, 2017
1.3.2 Aug 15, 2017
1.3.1 Aug 07, 2017
1.3.0 Aug 05, 2017
1.2.0 Jun 26, 2017
1.1.1 May 02, 2017
1.1.0 Apr 28, 2017
1.0.0 Mar 31, 2017
0.23.1 Mar 06, 2017
0.23.0 Feb 25, 2017
0.22.0 Dec 10, 2016
0.21.0 Nov 14, 2016
0.20.0 Sep 29, 2016
Extras:
Dependencies:
google-auth (<3.0.0,>=2.26.1)
google-api-core (<3.0.0,>=2.15.0)
google-cloud-core (<3.0.0,>=2.4.2)
google-resumable-media (<3.0.0,>=2.7.2)
requests (<3.0.0,>=2.22.0)
google-crc32c (<2.0.0,>=1.1.3)