mirror of
https://github.com/simon987/ws_bucket_client.git
synced 2025-04-03 15:53:00 +00:00
ws_bucket_client
Python client for ws_bucket
Usage (Library)
git submodule add https://github.com/simon987/ws_bucket_client
python -m pip install -r ws_bucket_client/requirements.txt
In your project
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)
Languages
Python
100%