obstore: Python Object Storage Interface

0.9.2 · active · verified Fri Apr 10

obstore is a Python library providing a simple, high-throughput interface for various object storage services like Amazon S3, Google Cloud Storage, Azure Blob Storage, and S3-compliant APIs. It features both synchronous and asynchronous APIs, streaming downloads/uploads, and automatic multipart uploads for large files, powered by a Rust backend for performance. The current version is 0.9.2, with a frequent release cadence, often introducing minor updates and fixes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize an in-memory object store and perform basic synchronous `put` and `get` operations. Note that operations like `put` and `get` are top-level functions within the `obstore` module, taking the store instance as their first argument. Asynchronous counterparts (e.g., `put_async`, `get_async`) are also available.

import obstore as obs
from obstore.store import MemoryStore

# Initialize an in-memory store for demonstration
store = MemoryStore()

# Define a file path and content
file_path = "my_document.txt"
file_content = b"Hello, obstore world!"

# Put the object into the store
obs.put(store, file_path, file_content)
print(f"Object '{file_path}' put into store.")

# Get the object from the store
response = obs.get(store, file_path)
retrieved_content = response.bytes()
print(f"Retrieved content: {retrieved_content.decode()}")

assert retrieved_content == file_content
print("Content matches!")

# Asynchronous operations are also available (requires an async context)
# async def main():
#    await obs.put_async(store, 'async_file.txt', b'async data')
#    res_async = await obs.get_async(store, 'async_file.txt')
#    print(f"Async retrieved: {res_async.bytes().decode()}")
# import asyncio
# asyncio.run(main())

view raw JSON →