https://github.com/giuppep/rstr-client
a remote client for rstr
https://github.com/giuppep/rstr-client
blob-store client python
Last synced: 3 months ago
JSON representation
a remote client for rstr
- Host: GitHub
- URL: https://github.com/giuppep/rstr-client
- Owner: giuppep
- License: mit
- Created: 2021-06-01T00:42:29.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-01-11T19:09:32.000Z (almost 2 years ago)
- Last Synced: 2025-10-01T07:36:11.155Z (3 months ago)
- Topics: blob-store, client, python
- Language: Python
- Homepage:
- Size: 203 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# rstr-client
A lightweight `python` API client for the [`rstr`](https://github.com/giuppep/rstr) blob store.
## Installation
You can install the `rstr-client` library with `pip`
```
pip install rstr-client
```
## Usage
```python
from rstr import Rstr
# Initialise the rstr client with the URL to your rstr server
# and your API Token.
# NOTE: these can be specified as environment variables
# >>> export RSTR_URL="https://my-rstr.rs"
# >>> export RSTR_TOKEN="MY_API_TOKEN"
url = "https://my-rstr.rs"
token = "MY_API_TOKEN"
with Rstr(url=url, token=token) as rstr:
# Add a file to the blob store
refs = rstr.add(["/path/to/my/file.txt"])
# You will get a list of references to your blobs
# e.g. ["f29bc64a9d3732b4b9035125fdb3285f5b6455778edca72414671e0ca3b2e0de"]
# You can then use the reference to retrieve your blob
ref = refs[0]
blob = rstr.get(ref)
print(blob)
# Blob(f29bc64a9d)
print(blob.metadata)
# BlobMetadata('file.txt', 'text/plain', 20 bytes)
# You can access the binary content of the blob with:
# content = blob.content
# The blob can be permanently deleted from the blob store with:
with Rstr(url=url, token=token) as rstr:
rstr.delete(ref)
```
## License
Copyright (c) 2021 giuppep
`rstr-client` is made available under the [MIT License](LICENSE)