Skip to main content

dcd-storage-client (Python SDK)

Official Python Client SDK for DevCloudDesk Storage Engine.

PyPI version Python versions License: MIT

High-performance, Cloudinary-compatible dynamic image transformations, uploads, and media management backed by your self-hosted DevCloudDesk storage clusters.


📦 Installation

pip install dcd-storage-client

Zero External Dependencies: Works out-of-the-box with standard Python 3.8+ (urllib based). Instant installation without dependency version conflicts!


🚀 Quickstart

1. Initialize Client

from dcd_storage_client import StorageClient

# Explicit configuration or auto-detected from DCD_STORAGE_ENDPOINT & DCD_STORAGE_API_KEY
client = StorageClient(
    endpoint="http://YOUR_SERVER_IP:7100",  # Or custom domain: https://storage.yourdomain.com
    api_key="dcd_key_live_xxxxxxxxxxxx",    # API key from DevCloudDesk dashboard
)

2. Upload Files

Upload from a local filepath, binary bytes, or file stream:

# Upload local file
asset = client.upload("profile.png", folder="avatars")
print("Public ID:", asset["publicId"])
print("CDN URL:", asset["url"])
print("Direct URL:", client.get_public_url(asset["publicId"]))

# Upload raw bytes or stream (e.g. in FastAPI or Flask)
asset = client.upload(
    file=image_bytes,
    folder="reports",
    filename="statement.pdf",
    overwrite=True
)

# Cloudinary-compatible namespace style also supported:
client.uploader.upload("banner.png", folder="marketing")
client.uploader.destroy(asset["publicId"])

3. Dynamic On-The-Fly Transformations

Generate real-time optimized WebP/AVIF images with automatic resizing, blur, and sharpening:

avatar_url = (
    client.url(asset["publicId"])
    .resize(width=400, height=400, crop="fill")
    .format("webp")
    .quality(85)
    .blur(4)
    .to_string()
)

print(avatar_url)
# => http://YOUR_SERVER_IP:7100/v1/image/w_400,h_400,c_fill,f_webp,q_85,e_blur_4/avatars/user-123.webp

Transformation Options Reference

Method Parameters Description
.resize(width, height, crop) int, int, str Resizes image dimension with crop strategy (fill, fit, crop, scale)
.crop(mode) 'fill' | 'fit' | 'crop' | 'scale' Crop strategy
.format(fmt) 'auto' | 'webp' | 'avif' | 'jpeg' | 'png' Output image format
.quality(q) int (1-100) Compression quality
.blur(sigma) int (1-100) Applies Gaussian blur filter
.grayscale() bool Converts image to grayscale
.sharpen() bool Sharpens image edges
.rotation(deg) int | 'auto' Rotates image by degrees (e.g. 90, 180, 270)

4. Client-Side Uploads via Signed Tokens (Zero Secret Exposure)

Keep your master API keys safely on your backend server. Generate short-lived, tamper-proof signed upload tokens for your frontend React/Next.js/Mobile clients:

# Generate short-lived upload token in your FastAPI / Django / Flask endpoint
token_data = client.create_signed_upload_token(
    folder="client-uploads",
    expires_in_seconds=300,        # 5 minutes
    max_bytes=10 * 1024 * 1024,   # 10 MB limit
)
print("Client Upload Token:", token_data["token"])

# Client or script can upload using ONLY the token (zero API key exposure)
client.upload_with_token(file_bytes, token=token_data["token"])

5. List Files & Server Stats

# List files in a folder
files = client.list_files(folder="avatars", page=1, limit=20)
print(f"Total files: {files['data']['pagination']['total']}")

# Server metrics
stats = client.get_stats()
print(f"Total bytes: {stats['totalStorageBytes']}, Driver: {stats['storageDriver']}")

6. Robust Error Handling

from dcd_storage_client import (
    StorageError,
    AuthenticationError,
    NotFoundError,
    PayloadTooLargeError,
    UploadError,
)

try:
    client.upload("large_video.mp4")
except AuthenticationError as e:
    print("Authentication failed. Check API key:", e)
except PayloadTooLargeError as e:
    print("File size exceeds limit:", e)
except UploadError as e:
    print("Upload failed:", e)

📜 License

MIT © DevCloudDesk

Metadata

Release files for dcd-storage-client 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dcd-storage-client 1.0.1
File Size Uploaded Provenance
dcd_storage_client-1.0.1.tar.gz 12.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dcd-storage-client 1.0.1
File Interpreter ABI Platform
dcd_storage_client-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.6 kB

Release files / dcd_storage_client-1.0.1.tar.gz

Download URL dcd_storage_client-1.0.1.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ba6960ad6eaa8a9a2c4587ebe9ce367861e33b6b7cdf4246fac4cf9fd585ec7e
BLAKE2b-256 checksum
How to use checksums
4a4c6fa552b5fd2e73f1b003f48b775b9c10dea9ff296ba17376146a500de503
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / dcd_storage_client-1.0.1-py3-none-any.whl

Download URL dcd_storage_client-1.0.1-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9f1e789ec7d2e4c36a7c567ebe25c2fcee891b8a068c3f62efda4d17299f4b35
BLAKE2b-256 checksum
How to use checksums
87270f4c70cfc312b536458fbbd370aa74053d912bf1b5f293f79807bee7f9da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Security for dcd-storage-client 1.0.1

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.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page