Metadata-Version: 2.4
Name: depozit
Version: 0.0.2
Summary: Python client for Depozit, a self-hosted file storage service
Author: Igor Rodrigues
License-Expression: MIT
Project-URL: Homepage, https://github.com/slim-devhub/depozit-python
Project-URL: Repository, https://github.com/slim-devhub/depozit-python
Project-URL: Issues, https://github.com/slim-devhub/depozit-python/issues
Project-URL: Server, https://github.com/slim-devhub/depozit-server
Keywords: depozit,storage,file-storage,self-hosted,grpc,client
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Framework :: AsyncIO
Classifier: Topic :: System :: Archiving
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Requires-Dist: aiogrpc>=1.8
Requires-Dist: grpcio-tools>=1.76.0
Requires-Dist: click>=8.0

# depozit-python

Python client for [Depozit](https://github.com/slim-devhub/depozit-server) — a self-hosted file storage service.

## Install

```bash
pip install depozit
```

## Server

```bash
depozit server install    # clone & run install.sh from depozit-server
depozit server uninstall  # stop service and remove binaries
```

Manage the running service:

```bash
depozit start
depozit stop
depozit status
```

## Usage

```python
import depozit

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

default.upload("photo.jpg", "images/photo.jpg")        # upload a file
default.upload_bytes(b"hello", "notes/hello.txt")      # upload raw bytes

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

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

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

## Containers

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

```python
uploads = depozit.connect("localhost:50051", api_key="your-api-key", container="uploads")
uploads.upload_bytes(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`.

```python
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:

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

## Async

```python
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")
```
