- 3.4.1 (latest)
- 3.4.0
- 3.3.1
- 3.2.0
- 3.1.1
- 3.0.0
- 2.19.0
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.0
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.1
- 2.1.0
- 2.0.0
- 1.44.0
- 1.43.0
- 1.42.3
- 1.41.1
- 1.40.0
- 1.39.0
- 1.38.0
- 1.37.1
- 1.36.2
- 1.35.1
- 1.34.0
- 1.33.0
- 1.32.0
- 1.31.2
- 1.30.0
- 1.29.0
- 1.28.1
- 1.27.0
- 1.26.0
- 1.25.0
- 1.24.1
- 1.23.0
- 1.22.0
- 1.21.0
- 1.20.0
- 1.19.0
- 1.18.0
- 1.17.0
Blobs / Objects
Create / interact with Google Cloud Storage blobs.
class google.cloud.storage.blob.Blob(name, bucket, chunk_size=None, encryption_key=None, kms_key_name=None, generation=None)
Bases: google.cloud.storage._helpers._PropertyMixin
A wrapper around Cloud Storage’s concept of an Object
.
Parameters
name (str) – The name of the blob. This corresponds to the unique path of the object in the bucket. If bytes, will be converted to a unicode object. Blob / object names can contain any sequence of valid unicode characters, of length 1-1024 bytes when UTF-8 encoded.
bucket (
google.cloud.storage.bucket.Bucket
) – The bucket to which this blob belongs.chunk_size (int) – (Optional) The size of a chunk of data whenever iterating (in bytes). This must be a multiple of 256 KB per the API specification. If not specified, the chunk_size of the blob itself is used. If that is not specified, a default value of 40 MB is used.
encryption_key (bytes) – (Optional) 32 byte encryption key for customer-supplied encryption. See https://cloud.google.com/storage/docs/encryption#customer-supplied.
kms_key_name (str) – (Optional) Resource name of Cloud KMS key used to encrypt the blob’s contents.
generation (long) – (Optional) If present, selects a specific revision of this object.
property name
Get the blob’s name.
STORAGE_CLASSES( = ('STANDARD', 'NEARLINE', 'COLDLINE', 'ARCHIVE', 'MULTI_REGIONAL', 'REGIONAL' )
Allowed values for storage_class
.
See https://cloud.google.com/storage/docs/json_api/v1/objects#storageClass https://cloud.google.com/storage/docs/per-object-storage-class
NOTE: This list does not include ‘DURABLE_REDUCED_AVAILABILITY’, which is only documented for buckets (and deprecated).
property acl()
Create our ACL on demand.
property bucket()
Bucket which contains the object.
Return type
Returns
The object’s bucket.
property cache_control()
HTTP ‘Cache-Control’ header for this object.
See RFC 7234 and API reference docs.
Return type
str or
NoneType
property chunk_size()
Get the blob’s default chunk size.
Return type
int or
NoneType
Returns
The current blob’s chunk size, if it is set.
property client()
The client bound to this blob.
property component_count()
Number of underlying components that make up this object.
See https://cloud.google.com/storage/docs/json_api/v1/objects
Return type
int or
NoneType
Returns
The component count (in case of a composed object) or
None
if the blob’s resource has not been loaded from the server. This property will not be set on objects not created viacompose
.
compose(sources, client=None, timeout=60, if_generation_match=None, if_metageneration_match=None, if_source_generation_match=None, retry=<google.cloud.storage.retry.ConditionalRetryPolicy object>)
Concatenate source blobs into this one.
If user_project
is set on the bucket, bills the API request
to that project.
Parameters
sources (list of
Blob
) – Blobs whose contents will be composed into this blob.client (
Client
) – (Optional) The client to use. If not passed, falls back to theclient
stored on the blob’s bucket.timeout (float* or [tuple*](https://python.readthedocs.io/en/latest/library/stdtypes.html#tuple)) – (Optional) The amount of time, in seconds, to wait for the server response. See: Configuring Timeouts
if_generation_match (long) – (Optional) Makes the operation conditional on whether the destination object’s current generation matches the given value. Setting to 0 makes the operation succeed only if there are no live versions of the object.
NOTE: In a previous version, this argument worked identically to the
if_source_generation_match
argument. For backwards-compatibility reasons, if a list is passed in, this argument will behave likeif_source_generation_match
and also issue a DeprecationWarning.if_metageneration_match (long) – (Optional) Makes the operation conditional on whether the destination object’s current metageneration matches the given value.
If a list of long is passed in, no match operation will be performed. (Deprecated: type(list of long) is supported for backwards-compatability reasons only.)
if_source_generation_match (list of long) – (Optional) Makes the operation conditional on whether the current generation of each source blob matches the corresponding generation. The list must match
sources
item-to-item.retry (google.api_core.retry.Retry* or [google.cloud.storage.retry.ConditionalRetryPolicy*](retry_timeout.md#google.cloud.storage.retry.ConditionalRetryPolicy)) – (Optional) How to retry the RPC. See: Configuring Retries
Example
Compose blobs using source generation match preconditions.
>>> from google.cloud import storage
>>> client = storage.Client()
>>> bucket = client.bucket("bucket-name")
>>> blobs = [bucket.blob("blob-name-1"), bucket.blob("blob-name-2")]
>>> if_source_generation_match = [None] * len(blobs)
>>> if_source_generation_match[0] = "123" # precondition for "blob-name-1"
>>> composed_blob = bucket.blob("composed-name")
>>> composed_blob.compose(blobs, if_source_generation_match=if_source_generation_match)
property content_disposition()
HTTP ‘Content-Disposition’ header for this object.
See RFC 6266 and API reference docs.
Return type
str or
NoneType
property content_encoding()
HTTP ‘Content-Encoding’ header for this object.
See RFC 7231 and API reference docs.
Return type
str or
NoneType
property content_language()
HTTP ‘Content-Language’ header for this object.
See BCP47 and API reference docs.
Return type
str or
NoneType
property content_type()
HTTP ‘Content-Type’ header for this object.
See RFC 2616 and API reference docs.
Return type
str or
NoneType
property crc32c()
CRC32C checksum for this object.
This returns the blob’s CRC32C checksum. To retrieve the value, first use a reload method of the Blob class which loads the blob’s properties from the server.
See RFC 4960 and API reference docs.
If not set before upload, the server will compute the hash.
Return type
str or
NoneType
Example
Retrieve the crc32c hash of blob.
>>> from google.cloud import storage
>>> client = storage.Client()
>>> bucket = client.get_bucket("my-bucket-name")
>>> blob = bucket.blob('my-blob')
>>> blob.crc32c # return None
>>> blob.reload()
>>> blob.crc32c # return crc32c hash
>>> # Another approach
>>> blob = bucket.get_blob('my-blob')
>>> blob.crc32c # return crc32c hash
create_resumable_upload_session(content_type=None, size=None, origin=None, client=None, timeout=60, checksum=None, if_generation_match=None, if_generation_not_match=None, if_metageneration_match=None, if_metageneration_not_match=None, retry=<google.cloud.storage.retry.ConditionalRetryPolicy object>)
Create a resumable upload session.
Resumable upload sessions allow you to start an upload session from one client and complete the session in another. This method is called by the initiator to set the metadata and limits. The initiator then passes the session URL to the client that will upload the binary data. The client performs a PUT request on the session URL to complete the upload. This process allows untrusted clients to upload to an access-controlled bucket. For more details, see the documentation on signed URLs.
The content type of the upload will be determined in order of precedence:
The value passed in to this method (if not
None
)The value stored on the current blob
The default value (‘application/octet-stream’)
NOTE: The effect of uploading to an existing blob depends on the “versioning” and “lifecycle” policies defined on the blob’s bucket. In the absence of those policies, upload will overwrite any existing contents.
See the object versioning and lifecycle API documents for details.
If encryption_key
is set, the blob will be encrypted with
a customer-supplied encryption key.
If user_project
is set on the bucket, bills the API request
to that project.
Parameters
size (int) – (Optional) The maximum number of bytes that can be uploaded using this session. If the size is not known when creating the session, this should be left blank.
content_type (str) – (Optional) Type of content being uploaded.
origin (str) – (Optional) If set, the upload can only be completed by a user-agent that uploads from the given origin. This can be useful when passing the session to a web client.
client (
Client
) – (Optional) The client to use. If not passed, falls back to theclient
stored on the blob’s bucket.timeout (float* or [tuple*](https://python.readthedocs.io/en/latest/library/stdtypes.html#tuple)) – (Optional) The amount of time, in seconds, to wait for the server response. See: Configuring Timeouts
checksum (str) – (Optional) The type of checksum to compute to verify the integrity of the object. After the upload is complete, the server-computed checksum of the resulting object will be checked and google.resumable_media.common.DataCorruption will be raised on a mismatch. On a validation failure, the client will attempt to delete the uploaded object automatically. Supported values are “md5”, “crc32c” and None. The default is None.
if_generation_match (long) – (Optional) See Using if_generation_match
if_generation_not_match (long) – (Optional) See Using if_generation_not_match
if_metageneration_match (long) – (Optional) See Using if_metageneration_match
if_metageneration_not_match (long) – (Optional) See Using if_metageneration_not_match
retry (google.api_core.retry.Retry* or [google.cloud.storage.retry.ConditionalRetryPolicy*](retry_timeout.md#google.cloud.storage.retry.ConditionalRetryPolicy)) – (Optional) How to retry the RPC. A None value will disable retries. A google.api_core.retry.Retry value will enable retries, and the object will define retriable response codes and errors and configure backoff and timeout options. A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and activates it only if certain conditions are met. This class exists to provide safe defaults for RPC calls that are not technically safe to retry normally (due to potential data duplication or other side-effects) but become safe to retry if a condition such as if_generation_match is set. See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for information on retry types and how to configure them. Media operations (downloads and uploads) do not support non-default predicates in a Retry object. The default will always be used. Other configuration changes for Retry objects such as delays and deadlines are respected.
Return type
Returns
The resumable upload session URL. The upload can be completed by making an HTTP PUT request with the file’s contents.
Raises
google.cloud.exceptions.GoogleCloudError
if the session creation response returns an error status.
property custom_time()
Retrieve the custom time for the object.
See https://cloud.google.com/storage/docs/json_api/v1/objects
Return type
datetime.datetime
orNoneType
Returns
Datetime object parsed from RFC3339 valid timestamp, or
None
if the blob’s resource has not been loaded from the server (seereload()
).
delete(client=None, if_generation_match=None, if_generation_not_match=None, if_metageneration_match=None, if_metageneration_not_match=None, timeout=60, retry=<google.cloud.storage.retry.ConditionalRetryPolicy object>)
Deletes a blob from Cloud Storage.
If user_project
is set on the bucket, bills the API request
to that project.
Parameters
client (
Client
) – (Optional) The client to use. If not passed, falls back to theclient
stored on the blob’s bucket.if_generation_match (long) – (Optional) See Using if_generation_match
if_generation_not_match (long) – (Optional) See Using if_generation_not_match
if_metageneration_match (long) – (Optional) See Using if_metageneration_match
if_metageneration_not_match (long) – (Optional) See Using if_metageneration_not_match
timeout (float* or [tuple*](https://python.readthedocs.io/en/latest/library/stdtypes.html#tuple)) – (Optional) The amount of time, in seconds, to wait for the server response. See: Configuring Timeouts
retry (google.api_core.retry.Retry* or [google.cloud.storage.retry.ConditionalRetryPolicy*](retry_timeout.md#google.cloud.storage.retry.ConditionalRetryPolicy)) – (Optional) How to retry the RPC. See: Configuring Retries
Raises
google.cloud.exceptions.NotFound
(propagated fromgoogle.cloud.storage.bucket.Bucket.delete_blob()
).
download_as_bytes(client=None, start=None, end=None, raw_download=False, if_etag_match=None, if_etag_not_match=None, if_generation_match=None, if_generation_not_match=None, if_metageneration_match=None, if_metageneration_not_match=None, timeout=60, checksum='md5', retry=<google.api_core.retry.Retry object>)
Download the contents of this blob as a bytes object.
If user_project
is set on the bucket, bills the API request
to that project.
Parameters
client (
Client
) – (Optional) The client to use. If not passed, falls back to theclient
stored on the blob’s bucket.start (int) – (Optional) The first byte in a range to be downloaded.
end (int) – (Optional) The last byte in a range to be downloaded.
raw_download (bool) – (Optional) If true, download the object without any expansion.
if_etag_match (Union[str, **Set[str]]) – (Optional) See Using if_etag_match
if_etag_not_match (Union[str, **Set[str]]) – (Optional) See Using if_etag_not_match
if_generation_match (long) – (Optional) See Using if_generation_match
if_generation_not_match (long) – (Optional) See Using if_generation_not_match
if_metageneration_match (long) – (Optional) See Using if_metageneration_match
if_metageneration_not_match (long) – (Optional) See Using if_metageneration_not_match
timeout (float* or [tuple*](https://python.readthedocs.io/en/latest/library/stdtypes.html#tuple)) – (Optional) The amount of time, in seconds, to wait for the server response. See: Configuring Timeouts
checksum (str) – (Optional) The type of checksum to compute to verify the integrity of the object. The response headers must contain a checksum of the requested type. If the headers lack an appropriate checksum (for instance in the case of transcoded or ranged downloads where the remote service does not know the correct checksum, including downloads where chunk_size is set) an INFO-level log will be emitted. Supported values are “md5”, “crc32c” and None. The default is “md5”.
retry (google.api_core.retry.Retry* or [google.cloud.storage.retry.ConditionalRetryPolicy*](retry_timeout.md#google.cloud.storage.retry.ConditionalRetryPolicy)) – (Optional) How to retry the RPC. A None value will disable retries. A google.api_core.retry.Retry value will enable retries, and the object will define retriable response codes and errors and configure backoff and timeout options.
A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and activates it only if certain conditions are met. This class exists to provide safe defaults for RPC calls that are not technically safe to retry normally (due to potential data duplication or other side-effects) but become safe to retry if a condition such as if_metageneration_match is set.
See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for information on retry types and how to configure them.
Media operations (downloads and uploads) do not support non-default predicates in a Retry object. The default will always be used. Other configuration changes for Retry objects such as delays and deadlines are respected.
Return type
Returns
The data stored in this blob.
Raises
google.cloud.exceptions.NotFound
download_as_string(client=None, start=None, end=None, raw_download=False, if_etag_match=None, if_etag_not_match=None, if_generation_match=None, if_generation_not_match=None, if_metageneration_match=None, if_metageneration_not_match=None, timeout=60, retry=<google.api_core.retry.Retry object>)
(Deprecated) Download the contents of this blob as a bytes object.
If user_project
is set on the bucket, bills the API request
to that project.
NOTE: Deprecated alias for download_as_bytes()
.
Parameters
client (
Client
) – (Optional) The client to use. If not passed, falls back to theclient
stored on the blob’s bucket.start (int) – (Optional) The first byte in a range to be downloaded.
end (int) – (Optional) The last byte in a range to be downloaded.
raw_download (bool) – (Optional) If true, download the object without any expansion.
if_etag_match (Union[str, **Set[str]]) – (Optional) See Using if_etag_match
if_etag_not_match (Union[str, **Set[str]]) – (Optional) See Using if_etag_not_match
if_generation_match (long) – (Optional) See Using if_generation_match
if_generation_not_match (long) – (Optional) See Using if_generation_not_match
if_metageneration_match (long) – (Optional) See Using if_metageneration_match
if_metageneration_not_match (long) – (Optional) See Using if_metageneration_not_match
timeout (float* or [tuple*](https://python.readthedocs.io/en/latest/library/stdtypes.html#tuple)) – (Optional) The amount of time, in seconds, to wait for the server response. See: Configuring Timeouts
retry (google.api_core.retry.Retry* or [google.cloud.storage.retry.ConditionalRetryPolicy*](retry_timeout.md#google.cloud.storage.retry.ConditionalRetryPolicy)) – (Optional) How to retry the RPC. A None value will disable retries. A google.api_core.retry.Retry value will enable retries, and the object will define retriable response codes and errors and configure backoff and timeout options.
A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and activates it only if certain conditions are met. This class exists to provide safe defaults for RPC calls that are not technically safe to retry normally (due to potential data duplication or other side-effects) but become safe to retry if a condition such as if_metageneration_match is set.
See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for information on retry types and how to configure them.
Media operations (downloads and uploads) do not support non-default predicates in a Retry object. The default will always be used. Other configuration changes for Retry objects such as delays and deadlines are respected.
Return type
Returns
The data stored in this blob.
Raises
google.cloud.exceptions.NotFound
download_as_text(client=None, start=None, end=None, raw_download=False, encoding=None, if_etag_match=None, if_etag_not_match=None, if_generation_match=None, if_generation_not_match=None, if_metageneration_match=None, if_metageneration_not_match=None, timeout=60, retry=<google.api_core.retry.Retry object>)
Download the contents of this blob as text (not bytes).
If user_project
is set on the bucket, bills the API request
to that project.
Parameters
client (
Client
) – (Optional) The client to use. If not passed, falls back to theclient
stored on the blob’s bucket.start (int) – (Optional) The first byte in a range to be downloaded.
end (int) – (Optional) The last byte in a range to be downloaded.
raw_download (bool) – (Optional) If true, download the object without any expansion.
encoding (str) – (Optional) encoding to be used to decode the downloaded bytes. Defaults to the
charset
param of attr:content_type, or else to “utf-8”.if_etag_match (Union[str, **Set[str]]) – (Optional) See Using if_etag_match
if_etag_not_match (Union[str, **Set[str]]) – (Optional) See Using if_etag_not_match
if_generation_match (long) – (Optional) See Using if_generation_match
if_generation_not_match (long) – (Optional) See Using if_generation_not_match
if_metageneration_match (long) – (Optional) See Using if_metageneration_match
if_metageneration_not_match (long) – (Optional) See Using if_metageneration_not_match
timeout (float* or [tuple*](https://python.readthedocs.io/en/latest/library/stdtypes.html#tuple)) – (Optional) The amount of time, in seconds, to wait for the server response. See: Configuring Timeouts
retry (google.api_core.retry.Retry* or [google.cloud.storage.retry.ConditionalRetryPolicy*](retry_timeout.md#google.cloud.storage.retry.ConditionalRetryPolicy)) – (Optional) How to retry the RPC. A None value will disable retries. A google.api_core.retry.Retry value will enable retries, and the object will define retriable response codes and errors and configure backoff and timeout options.
A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and activates it only if certain conditions are met. This class exists to provide safe defaults for RPC calls that are not technically safe to retry normally (due to potential data duplication or other side-effects) but become safe to retry if a condition such as if_metageneration_match is set.
See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for information on retry types and how to configure them.
Media operations (downloads and uploads) do not support non-default predicates in a Retry object. The default will always be used. Other configuration changes for Retry objects such as delays and deadlines are respected.
Return type
text
Returns
The data stored in this blob, decoded to text.
download_to_file(file_obj, client=None, start=None, end=None, raw_download=False, if_etag_match=None, if_etag_not_match=None, if_generation_match=None, if_generation_not_match=None, if_metageneration_match=None, if_metageneration_not_match=None, timeout=60, checksum='md5', retry=<google.api_core.retry.Retry object>)
DEPRECATED. Download the contents of this blob into a file-like object.
NOTE: If the server-set property, media_link
, is not yet
initialized, makes an additional API request to load it.
Downloading a file that has been encrypted with a customer-supplied encryption key:
from google.cloud.storage import Blob client = storage.Client(project="my-project") bucket = client.get_bucket("my-bucket") encryption_key = "c7f32af42e45e85b9848a6a14dd2a8f6" blob = Blob("secure-data", bucket, encryption_key=encryption_key) blob.upload_from_string("my secret message.") with open("/tmp/my-secure-file", "wb") as file_obj: client.download_to_file(blob, file_obj)
The encryption_key
should be a str or bytes with a length of at
least 32.
If the chunk_size
of a current blob is None, will download data
in single download request otherwise it will download the chunk_size
of data in each request.
For more fine-grained control over the download process, check out google-resumable-media. For example, this library allows downloading parts of a blob rather than the whole thing.
If user_project
is set on the bucket, bills the API request
to that project.
Parameters
file_obj (file) – A file handle to which to write the blob’s data.
client (
Client
) – (Optional) The client to use. If not passed, falls back to theclient
stored on the blob’s bucket.start (int) – (Optional) The first byte in a range to be downloaded.
end (int) – (Optional) The last byte in a range to be downloaded.
raw_download (bool) – (Optional) If true, download the object without any expansion.
if_etag_match (Union[str, **Set[str]]) – (Optional) See Using if_etag_match
if_etag_not_match (Union[str, **Set[str]]) – (Optional) See Using if_etag_not_match
if_generation_match (long) – (Optional) See Using if_generation_match
if_generation_not_match (long) – (Optional) See Using if_generation_not_match
if_metageneration_match (long) – (Optional) See Using if_metageneration_match
if_metageneration_not_match (long) – (Optional) See Using if_metageneration_not_match
timeout (float* or [tuple*](https://python.readthedocs.io/en/latest/library/stdtypes.html#tuple)) – (Optional) The amount of time, in seconds, to wait for the server response. See: Configuring Timeouts
checksum (str) – (Optional) The type of checksum to compute to verify the integrity of the object. The response headers must contain a checksum of the requested type. If the headers lack an appropriate checksum (for instance in the case of transcoded or ranged downloads where the remote service does not know the correct checksum, including downloads where chunk_size is set) an INFO-level log will be emitted. Supported values are “md5”, “crc32c” and None. The default is “md5”.
retry (google.api_core.retry.Retry* or [google.cloud.storage.retry.ConditionalRetryPolicy*](retry_timeout.md#google.cloud.storage.retry.ConditionalRetryPolicy)) – (Optional) How to retry the RPC. A None value will disable retries. A google.api_core.retry.Retry value will enable retries, and the object will define retriable response codes and errors and configure backoff and timeout options.
A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and activates it only if certain conditions are met. This class exists to provide safe defaults for RPC calls that are not technically safe to retry normally (due to potential data duplication or other side-effects) but become safe to retry if a condition such as if_metageneration_match is set.
See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for information on retry types and how to configure them.
Media operations (downloads and uploads) do not support non-default predicates in a Retry object. The default will always be used. Other configuration changes for Retry objects such as delays and deadlines are respected.
Raises
google.cloud.exceptions.NotFound
download_to_filename(filename, client=None, start=None, end=None, raw_download=False, if_etag_match=None, if_etag_not_match=None, if_generation_match=None, if_generation_not_match=None, if_metageneration_match=None, if_metageneration_not_match=None, timeout=60, checksum='md5', retry=<google.api_core.retry.Retry object>)
Download the contents of this blob into a named file.
If user_project
is set on the bucket, bills the API request
to that project.
Parameters
filename (str) – A filename to be passed to
open
.client (
Client
) – (Optional) The client to use. If not passed, falls back to theclient
stored on the blob’s bucket.start (int) – (Optional) The first byte in a range to be downloaded.
end (int) – (Optional) The last byte in a range to be downloaded.
raw_download (bool) – (Optional) If true, download the object without any expansion.
if_etag_match (Union[str, **Set[str]]) – (Optional) See Using if_etag_match
if_etag_not_match (Union[str, **Set[str]]) – (Optional) See Using if_etag_not_match
if_generation_match (long) – (Optional) See Using if_generation_match
if_generation_not_match (long) – (Optional) See Using if_generation_not_match
if_metageneration_match (long) – (Optional) See Using if_metageneration_match
if_metageneration_not_match (long) – (Optional) See Using if_metageneration_not_match
timeout (float* or [tuple*](https://python.readthedocs.io/en/latest/library/stdtypes.html#tuple)) – (Optional) The amount of time, in seconds, to wait for the server response. See: Configuring Timeouts
checksum (str) – (Optional) The type of checksum to compute to verify the integrity of the object. The response headers must contain a checksum of the requested type. If the headers lack an appropriate checksum (for instance in the case of transcoded or ranged downloads where the remote service does not know the correct checksum, including downloads where chunk_size is set) an INFO-level log will be emitted. Supported values are “md5”, “crc32c” and None. The default is “md5”.
retry (google.api_core.retry.Retry* or [google.cloud.storage.retry.ConditionalRetryPolicy*](retry_timeout.md#google.cloud.storage.retry.ConditionalRetryPolicy)) – (Optional) How to retry the RPC. A None value will disable retries. A google.api_core.retry.Retry value will enable retries, and the object will define retriable response codes and errors and configure backoff and timeout options.
A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and activates it only if certain conditions are met. This class exists to provide safe defaults for RPC calls that are not technically safe to retry normally (due to potential data duplication or other side-effects) but become safe to retry if a condition such as if_metageneration_match is set.
See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for information on retry types and how to configure them.
Media operations (downloads and uploads) do not support non-default predicates in a Retry object. The default will always be used. Other configuration changes for Retry objects such as delays and deadlines are respected.
Raises
google.cloud.exceptions.NotFound
property encryption_key()
Retrieve the customer-supplied encryption key for the object.
Return type
bytes or
NoneType
Returns
The encryption key or
None
if no customer-supplied encryption key was used, or the blob’s resource has not been loaded from the server.
property etag()
Retrieve the ETag for the object.
See RFC 2616 (etags) and API reference docs.
Return type
str or
NoneType
Returns
The blob etag or
None
if the blob’s resource has not been loaded from the server.
property event_based_hold()
Is an event-based hold active on the object?
See API reference docs.
If the property is not set locally, returns None
.
Return type
bool or
NoneType
exists(client=None, if_etag_match=None, if_etag_not_match=None, if_generation_match=None, if_generation_not_match=None, if_metageneration_match=None, if_metageneration_not_match=None, timeout=60, retry=<google.api_core.retry.Retry object>)
Determines whether or not this blob exists.
If user_project
is set on the bucket, bills the API request
to that project.