Skip to main content

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 file
  • bulk_upload(*uploads: dict) -> List[ZenUpload]: Upload multiple files
  • generate_signed_url(options: dict) -> str: Generate a signed URL
  • delete_by_url(url: str) -> bool: Delete a file by URL

ZenUpload

Represents a file upload operation.

Properties

  • file: ZenFile: Uploaded file information
  • error: ZenError: Upload error if any
  • is_completed: bool: Whether upload is completed
  • is_cancelled: bool: Whether upload is cancelled

Methods

  • upload() -> ZenUpload: Perform the upload operation
  • cancel(): 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

filezen_python-0.1.3.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

filezen_python-0.1.3-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file filezen_python-0.1.3.tar.gz.

File metadata

  • Download URL: filezen_python-0.1.3.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for filezen_python-0.1.3.tar.gz
Algorithm Hash digest
SHA256 b4dea8b593b2aa8e8b8634b0f007c7b8f7c4e38ec1f47c0a8f74e6e89a2d0a35
MD5 1bd4968689f41806c6781113249b5147
BLAKE2b-256 59bad3e844df02229658d39b428d7e5acf612f86aec50d58931d6f9dce11a757

See more details on using hashes here.

File details

Details for the file filezen_python-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: filezen_python-0.1.3-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.12.9

File hashes

Hashes for filezen_python-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7882b5c499a8e156e88cd2ddb4544308508d8944373a94bbd5a678ed260ea608
MD5 ed84a27c66c3aca110947023d610093b
BLAKE2b-256 09737b666a4d23d0088a2008f3a4f625ae5f3f1faf24da3c8e20e5fbd80370ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page