Python SDK for FileZen file management service
Project description
FileZen Python SDK
A Python SDK for FileZen, providing easy file upload and management capabilities.
Features
- ✅ File Upload: Upload single files efficiently
- ✅ Bulk Upload: Upload multiple files concurrently
- ✅ URL Upload: Upload files directly from URLs
- ✅ Signed URLs: Generate secure signed URLs for direct uploads
- ✅ Multipart Upload: Automatic multipart upload for large files (>10MB)
- ✅ File Deletion: Delete files by URL
- ✅ Error Handling: Comprehensive error handling and retry logic
- ✅ Backend Optimized: Designed for server-side usage without UI dependencies
Installation
pip install filezen-python
Quick Start
import asyncio
from filezen import ZenStorage
async def main():
# Initialize storage
storage = ZenStorage({
"api_key": "your_api_key_here", # Optional: can use FILEZEN_API_KEY env var
})
# Upload a single file
with open("my_file.jpg", "rb") as f:
upload = await storage.upload(f.read(), {
"name": "my_file.jpg",
"mime_type": "image/jpeg",
})
print(f"File uploaded: {upload.file.url}")
# Upload multiple files
uploads = await storage.bulk_upload(
{"source": file1_content, "options": {"name": "file1.jpg"}},
{"source": file2_content, "options": {"name": "file2.png"}},
)
# Generate a signed URL
signed_url = storage.generate_signed_url({
"file_key": "my_file.jpg",
"expires_in": 3600, # 1 hour
})
asyncio.run(main())
Multipart Upload
The SDK automatically uses multipart upload for files larger than 10MB. This provides:
- Resumable uploads: Upload can be resumed if interrupted
- Better performance: Parallel chunk uploads
- Progress tracking: Detailed progress for each chunk
- Error recovery: Automatic retry for failed chunks
# Large files are automatically handled with multipart upload
with open("large_video.mp4", "rb") as f:
upload = await storage.upload(f.read(), {
"name": "large_video.mp4",
"mime_type": "video/mp4",
})
# Automatically uses multipart upload for files > 10MB
Configuration
storage = ZenStorage({
"api_key": "your_api_key", # FileZen API key
"api_url": "https://api.filezen.dev", # API base URL
"keep_uploads": True, # Whether to track uploads in memory
})
Environment Variables
You can also set configuration via environment variables:
export FILEZEN_API_KEY="your_api_key_here"
export FILEZEN_API_URL="https://api.filezen.dev" # Optional
API Reference
ZenStorage
Main storage class for FileZen operations.
Methods
upload(source: bytes, options: dict) -> ZenUpload: Upload a single filebulk_upload(*uploads: dict) -> List[ZenUpload]: Upload multiple filesgenerate_signed_url(options: dict) -> str: Generate a signed URLdelete_by_url(url: str) -> bool: Delete a file by URL
ZenUpload
Represents a file upload operation.
Properties
file: ZenFile: Uploaded file informationerror: ZenError: Upload error if anyis_completed: bool: Whether upload is completedis_cancelled: bool: Whether upload is cancelled
Methods
upload() -> ZenUpload: Perform the upload operationcancel(): Cancel the upload
Examples
See the FastAPI example app for a complete implementation with web interface.
Documentation
For detailed documentation, visit docs.filezen.dev
License
MIT License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file filezen_python-0.1.0.tar.gz.
File metadata
- Download URL: filezen_python-0.1.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9f598144cbe7035c09f1675e42dcfc15c9cbf6b28eba07cdcba00107f000f39
|
|
| MD5 |
db0ed04b9217ddb00c1f4be4bfa1b9bc
|
|
| BLAKE2b-256 |
748a82fdf0924305f292cbb596d8c243d3a87316ef02e0b5d348aeeb7e4d67a4
|
File details
Details for the file filezen_python-0.1.0-py3-none-any.whl.
File metadata
- Download URL: filezen_python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9de4cabbd1322dee03af31d03720f773b40444822deb3e3981922fc3483e8574
|
|
| MD5 |
3b4aff2b96886fa7052945ac19733905
|
|
| BLAKE2b-256 |
8a0d60b1a0d72fe220d4fa2e8d5a50b5ea3f45535a85511e63c8a3aac06f106a
|