quantahost-storage (Python)
Official Python SDK for QuantaHost object storage (QuantaStore). Uploads go direct to storage via short-lived presigned URLs — file bytes never transit the QuantaHost API, and your secret stays on your server. Zero dependencies (standard library only). Python 3.8+.
pip install quantahost-storage
from quantahost_storage import QuantaStorage
from datetime import timedelta
storage = QuantaStorage(api_key="qhk_...", api_secret="qhs_...")
# or QuantaStorage() # reads QUANTAHOST_STORAGE_KEY / _SECRET from the env
# Upload a file (keeps its name) or raw bytes
result = storage.upload("cat.png")
result = storage.upload(photo_bytes, "avatars/user-42.png", "image/png")
# Persist result.object_path — the server randomizes the leaf name, so it's the
# only handle that fetches/deletes the file later.
print(result.object_path, result.size)
# Private bucket: hand the browser a short-lived signed link (do your auth first)
url = storage.signed_url(result.object_path, expires_in=300).url # 5 min
# Public bucket: permanent URL
url = storage.public_url(result.object_path)
# List / delete
for obj in storage.list(prefix="avatars/").objects:
print(obj.object_path, obj.size)
storage.delete(result.object_path)
Django / Flask example
# Flask
@app.post("/upload")
def upload():
f = request.files["file"]
r = storage.upload(f.read(), f"users/{g.user.id}/{f.filename}", f.mimetype)
return {"path": r.object_path}
@app.get("/file/<path:object_path>")
def file(object_path):
# authorize the user for this file FIRST, then sign
return redirect(storage.signed_url(object_path, expires_in=300).url)
- Files ≤100 MB use a single PUT; larger (up to 1 GB) switch to multipart automatically.
- One
QuantaStorageinstance is thread-safe — create it once and reuse it. - Errors raise
QuantaStorageError(.status,.code,.is_unauthorized,.is_not_found,.is_too_large).
Config
Pass credentials directly, or via env: QUANTAHOST_STORAGE_KEY, QUANTAHOST_STORAGE_SECRET, optional QUANTAHOST_STORAGE_CLOUD, QUANTAHOST_API_URL, or a single QUANTASTORE_URL=quantastore://<key>:<secret>@<cloud>. For an on-prem QuantaHost behind a private CA, pass ca_cert="/path/ca.pem".
Security
HTTPS only (plain http allowed for localhost dev), never follows redirects, validates object paths (no ../control chars), blocks header injection, bounds upload size, and never prints the secret (repr redacts it).
Test / build
python3 tests/test_guards.py # offline guard tests
python3 -m build # build sdist + wheel (needs: pip install build)
See the publishing guide for releasing to PyPI. Report security issues to security@quantahost.net.
Web-framework uploads (FastAPI / Flask / Django)
from quantahost_storage import QuantaStorage
from quantahost_storage.frameworks import upload_file
storage = QuantaStorage(api_key=..., api_secret=...)
# FastAPI
@app.post("/upload")
async def handle(file: UploadFile):
r = upload_file(storage, file) # sync; reads file.file
return {"path": r.object_path, "url": r.public_url}
# Flask / Werkzeug
r = upload_file(storage, request.files["photo"])
# Django
r = upload_file(storage, request.FILES["photo"])
upload_file duck-types the upload object — no framework is imported, so the SDK stays
zero-dependency. Pass object_path= / content_type= to override; the filename is used
otherwise (the server randomizes the leaf name so uploads never collide).
Metadata
Release files for quantahost-storage 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| quantahost_storage-0.1.0.tar.gz | 13.4 kB | Without provenance | Details for quantahost_storage-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| quantahost_storage-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for quantahost_storage-0.1.0-py3-none-any.whl |
Total release size: 24.4 kB
Release files / quantahost_storage-0.1.0.tar.gz
| Download URL | quantahost_storage-0.1.0.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
15cfba1f34f1760680689aa6b9258f5ee1ed4f8f7b207e89568dbd2b954a369f
|
|
BLAKE2b-256 checksum How to use checksums |
ff2c462eba388ff6b80f8db67314fd5fbe394378f5da130dde22e89205cd1248
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Release files / quantahost_storage-0.1.0-py3-none-any.whl
| Download URL | quantahost_storage-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
37ea9542dfea963a292d558b23e517358c011d67c7c4b8aa75b7cb8f1c19b634
|
|
BLAKE2b-256 checksum How to use checksums |
2e7c9e43b04050e63aaaefe31e60e4afdab07a82d90c59cf441af17be9ae3b0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Security for quantahost-storage 0.1.0
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.