blobfile
blobfile is a Python library that provides a unified interface for reading and writing files across local and remote blob storage systems, including Google Cloud Storage (GCS) and Azure Blob Storage (ABS). It offers an API similar to Python's built-in `open()` function, along with equivalents of common `os.path` and `shutil` operations. The current version is 3.2.0, released in April 2026, with a release cadence of approximately one major version per year.
Warnings
- breaking In version 2.0.0, the default values for `configure` were changed to `output_az_paths=True` and `save_access_token_to_disk=True`.
- gotcha Azure Blob Storage does not support multiple writers for the same blob; concurrent writes may lead to `ConcurrentWriteFailure` errors.
- gotcha When using `streaming=True` in `BlobFile`, appending to files is not implemented.
- gotcha The `glob` function supports glob-style patterns but does not support character ranges.
- gotcha When writing to Azure Blob Storage, the `version` parameter can be used to ensure the remote version matches; mismatches raise a `VersionMismatch` error.
Install
-
pip install blobfile
Imports
- BlobFile
from blobfile import BlobFile
- exists
from blobfile import exists
Quickstart
import blobfile as bf
# Write a file to Google Cloud Storage
with bf.BlobFile('gs://my-bucket-name/cats', 'wb') as f:
f.write(b'meow!')
# Check if the file exists
print('exists:', bf.exists('gs://my-bucket-name/cats'))
# Read the file back
with bf.BlobFile('gs://my-bucket-name/cats', 'rb') as f:
print('contents:', f.read())