https://github.com/simon987/ws_bucket_client
Python client for https://github.com/simon987/ws_bucket
https://github.com/simon987/ws_bucket_client
Last synced: about 1 year ago
JSON representation
Python client for https://github.com/simon987/ws_bucket
- Host: GitHub
- URL: https://github.com/simon987/ws_bucket_client
- Owner: simon987
- License: gpl-3.0
- Created: 2019-03-09T23:40:13.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-01T18:08:33.000Z (about 7 years ago)
- Last Synced: 2025-02-09T20:18:20.354Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.codefactor.io/repository/github/simon987/ws_bucket)

# ws_bucket_client
Python client for [ws_bucket](https://github.com/simon987/ws_bucket)
## Usage (Library)
```bash
git submodule add https://github.com/simon987/ws_bucket_client
python -m pip install -r ws_bucket_client/requirements.txt
```
In your project
```python
import datetime
from ws_bucket_client.api import WsBucketApi
WSB_API = "http://exemple-api-url/"
WSB_SECRET = "exemple_secret" # Set to None for non-administrative usage
ws_bucket = WsBucketApi(WSB_API, WSB_SECRET)
# Allocate bucket (Requires secret)
ws_bucket.allocate(
token="aj8209x48m",
file_name="tmp_file.ndjson",
max_size=1024 * 1024,
upload_hook="rclone copy $1 my_gdrive:/wsb_tmp && rm $1",
to_dispose_date=int(datetime.datetime.now().timestamp()) + 4000
)
# Get bucket data
ws_bucket.read(token="aj8209x48m")
# Upload data to bucket, will trigger upload_hook
with open("my_file.ndjson", "rb") as f:
ws_bucket.upload(token="aj8209x48m", stream=f, max_size=100000)
```