This document provides a high-level overview of the main components of the Google Cloud Storage Python client library.
The Client class is the entry point for interacting with the Google Cloud Storage API. It handles authentication and project configuration.
- Key Responsibilities:
- Authenticating with Google Cloud.
- Creating, retrieving, and listing buckets.
- Managing batch operations.
- Creating HMAC keys.
The Bucket class represents a Google Cloud Storage bucket. It provides methods to manage the bucket itself and the objects (blobs) within it.
- Key Responsibilities:
- Creating and deleting the bucket.
- Configuring bucket properties (ACLs, lifecycle rules, versioning, CORS, website configuration, etc.).
- Creating, listing, getting, and deleting blobs.
- Managing IAM policies for the bucket.
The Blob class represents an object (file) within a GCS bucket. It provides methods to upload, download, and manage the object.
- Key Responsibilities:
- Uploading data (from file, filename, or string).
- Downloading data (to file, filename, bytes, or text).
- Managing object metadata and ACLs.
- Deleting the object.
- Generating signed URLs for temporary access.
The Batch class allows grouping multiple API calls into a single HTTP request. This is useful for performing multiple operations (like patching or deleting multiple blobs) efficiently.
- Key Responsibilities:
- Accumulating multiple requests.
- Sending them in a single
multipart/mixedHTTP request. - Processing the responses.
The transfer_manager module provides utilities for concurrent uploads and downloads, which can significantly improve performance for large numbers of files or large files.
- Key Responsibilities:
upload_many/upload_many_from_filenames: Uploading multiple files concurrently.download_many/download_many_to_path: Downloading multiple blobs concurrently.download_chunks_concurrently: Downloading a single large file in chunks concurrently.upload_chunks_concurrently: Uploading a single large file in chunks concurrently (using XML Multi-Part Upload).
google/cloud/storage/: Contains the source code for the library.tests/: Contains unit and system tests.samples/: Contains code samples demonstrating how to use the library.