Skip to main content

Cloud Storage Manager

A Python package for seamlessly managing file uploads across AWS S3 and Google Cloud Storage platforms.

Features

  • Unified interface for AWS S3 and Google Cloud Storage
  • Async operations support
  • Pre-signed URL generation
  • Easy file upload and deletion
  • Type-safe configuration using Pydantic
  • Comprehensive error handling
  • Logging support

Installation

pip install cloud-storage-manager

Quick Start

AWS S3 Example

import asyncio
from cloud_storage_manager import CloudStorageFactory, StorageProvider, StorageConfig, AwsConfig

async def main():
    # Configure AWS
    config = StorageConfig(
        aws=AwsConfig(
            bucket_name="my-bucket",
            access_key_id="your-access-key",
            secret_access_key="your-secret-key",
            region="us-east-1"  # optional, defaults to us-east-1
        )
    )
    
    # Create storage client
    storage = CloudStorageFactory.get_storage(StorageProvider.AWS, config)
    
    # Upload file
    cloud_path = await storage.upload("local/path/file.txt", "remote/path/file.txt")
    
    # Generate temporary URL
    url = await storage.get_public_url(cloud_path, expiration=3600)  # 1 hour expiration
    
    # Delete file
    success = await storage.delete(cloud_path)

asyncio.run(main())

Google Cloud Storage Example

import asyncio
from cloud_storage_manager import CloudStorageFactory, StorageProvider, StorageConfig, GcpConfig

async def main():
    # Configure GCP
    config = StorageConfig(
        gcp=GcpConfig(
            bucket_name="my-bucket",
            project_id="your-project-id",
            credentials={
                # Your service account credentials dictionary
            }
        )
    )
    
    # Create storage client
    storage = CloudStorageFactory.get_storage(StorageProvider.GCP, config)
    
    # Upload file
    cloud_path = await storage.upload("local/path/file.txt", "remote/path/file.txt")
    
    # Generate temporary URL
    url = await storage.get_public_url(cloud_path, expiration=3600)  # 1 hour expiration
    
    # Delete file
    success = await storage.delete(cloud_path)

asyncio.run(main())

Error Handling

The package provides specific exceptions for different types of errors:

from cloud_storage_manager import UploadError, DeleteError, DownloadError

try:
    await storage.upload("file.txt", "remote/file.txt")
except UploadError as e:
    print(f"Upload failed: {e}")

Configuration

AWS Configuration

  • bucket_name: Name of your S3 bucket
  • access_key_id: AWS access key ID
  • secret_access_key: AWS secret access key
  • region: AWS region (optional, defaults to us-east-1)

GCP Configuration

  • bucket_name: Name of your GCP bucket
  • project_id: Your GCP project ID
  • credentials: Service account credentials dictionary

Development

To contribute to the project:

# Clone the repository
git clone https://github.com/yourusername/cloud-storage-manager.git

# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for cloud-storage-manager 0.1.2

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

Source distribution (sdist)

Source distribution for cloud-storage-manager 0.1.2
File Size Uploaded
cloud_storage_manager-0.1.2.tar.gz 10.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cloud-storage-manager 0.1.2
File Interpreter ABI Platform
cloud_storage_manager-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 20.7 kB

Release files / cloud_storage_manager-0.1.2.tar.gz

Download URL cloud_storage_manager-0.1.2.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5d7f7ac8164f1d8085c7df60c2c9a7e2160bfcf5f318598c0569426bc14b1651
BLAKE2b-256 checksum
How to use checksums
cba58f8596cc1871be7b080fa5a44edc528ee42fe675d38797cf9360653ae213
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / cloud_storage_manager-0.1.2-py3-none-any.whl

Download URL cloud_storage_manager-0.1.2-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
355137469fd70ca66ab2784e187ab6502791734086b3aa2c7fc83eeee70419ea
BLAKE2b-256 checksum
How to use checksums
513a95e8c42a23c58c7ac2b85b0a2984d7201096c6c84899e96a2eb02bd5a777
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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