Skip to main content

depozit-python

Python client for Depozit — a self-hosted file storage service.

Install

pip install depozit

Server

This package is only the client. To install and run the server, see depozit-server.

Usage

import depozit

default = depozit.connect("localhost:50051", api_key="your-api-key") # container default

default.upload("photo.jpg", "images/photo.jpg")        # upload a local file
default.upload(b"hello", "notes/hello.txt")            # upload raw bytes
default.upload_stream((c for c in [b"hel", b"lo"]), "notes/hello.txt")  # upload a generator of bytes

data = default.read("images/photo.jpg")                # read a whole file

with open("photo.jpg", "wb") as f:                     # read chunk by chunk
    for chunk in default.read_stream("images/photo.jpg"):
        f.write(chunk)

default.rename("notes/hello.txt", "greet.txt")         # rename, now notes/greet.txt
default.delete("images/photo.jpg")                     # delete

for path in default.find(prefix="images/"):            # list files
    print(path)

Errors raise Python exceptions: FileNotFoundError (missing file or container), FileExistsError (upload without overwrite, rename onto an existing file), PermissionError (wrong API key, deleting or renaming the default container), ValueError (invalid path or name). Anything else raises depozit.errors.DepozitError, with the gRPC status in code: RESOURCE_EXHAUSTED for an upload over the server's MAX_FILE_SIZE, DATA_LOSS for a stored file that fails its integrity check.

TLS

If the server sets TLS_CERT / TLS_KEY, connect with tls=True. For a self-signed certificate, pass it as root_certificates:

default = depozit.connect("myserver:50051", api_key="your-api-key", root_certificates=open("cert.pem", "rb").read())

Containers

Each connection is bound to one container. connect creates the container if it does not exist.

uploads = depozit.connect("localhost:50051", api_key="your-api-key", container="uploads")
uploads.upload_stream((c for c in [b"hello"]), "hello.txt")  # stored in "uploads"
uploads.close()

Only a client on the default container can manage containers. On any other container these methods raise PermissionError. This is a guard against mistakes, not a security boundary: the API key itself allows managing every container.

default = depozit.connect("localhost:50051", api_key="your-api-key")

default.create_container("backups")
default.rename_container("backups", "archive")
default.delete_container("archive")

Use with to close the connection automatically:

with depozit.connect("localhost:50051", api_key="your-api-key", container="uploads") as uploads:
    uploads.read("hello.txt")

Async

import depozit.aio

async with await depozit.aio.connect("localhost:50051", api_key="your-api-key") as default:
    data = await default.read("images/photo.jpg")

Metadata

Release files for depozit 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for depozit 0.0.3
File Interpreter ABI Platform Actions
depozit-0.0.3-py3-none-any.whl Python 3 none any Details for depozit-0.0.3-py3-none-any.whl

Release files / depozit-0.0.3-py3-none-any.whl

Download URL depozit-0.0.3-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
24760cb275c6a947e06501628ad27a4fbb2ce193a004734498d9980426406ad7
BLAKE2b-256 checksum
How to use checksums
872f8be93f5e404bd96eaca63e2360e9cf9d76b1a6ad9db34cbce2b402f2d59f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for depozit 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page