Skip to main content

Multi-cloud storage manager with automatic fallback for Git LFS (Cloudinary + Google Drive)

Project description

Flash Storage

Multi-cloud storage manager with automatic fallback for Git LFS

Store your large files in Cloudinary or Google Drive with intelligent automatic fallback. Perfect for Git LFS workflows, backups, and managing binary assets.

PyPI version Python 3.8+ License: MIT

โœจ Features

  • ๐ŸŒฉ๏ธ Dual Cloud Support: Cloudinary + Google Drive
  • ๐Ÿ”„ Automatic Fallback: Seamlessly switches when storage is full
  • ๐ŸŽฏ Smart Primary Storage: Choose your preferred cloud, auto-fallback to the other
  • ๐Ÿš€ Simple API: Clean Python library and CLI
  • ๐Ÿ”’ Secure: OAuth 2.0 for Google Drive, secure credential storage
  • ๐Ÿ“ฆ Git LFS Ready: Works as a custom transfer agent
  • ๐Ÿ†“ Free Tiers: Cloudinary (25GB) + Google Drive (15GB)

๐Ÿš€ Quick Start

Installation

pip install flash-storage

Setup

# Configure Cloudinary
flash setup

# Configure Google Drive (optional, for fallback)
flash setup-gdrive

# Set your primary storage
flash set-primary cloudinary  # or 'gdrive'

Basic Usage

# Upload a file (automatic fallback if primary is full)
flash push myfile.psd

# Download it back
flash pull myfile.psd

# Check status
flash status

๐Ÿ“š Usage

Command Line

# Upload files
flash push design.sketch
flash push video.mp4 -m "Add new video"

# Download files
flash pull design.sketch

# Switch primary storage
flash set-primary gdrive

# Check configuration
flash status

Python Library

from flash_storage import flash as fs

# Setup (one-time)
fs.setup("cloud-name", "api-key", "api-secret")

# Upload
result = fs.push("myfile.psd")
print(f"Uploaded to: {result['storage']}")  # 'cloudinary' or 'gdrive'
print(f"URL: {result['url']}")

# Download
fs.pull("myfile.psd")

# Check if exists
if fs.exists("myfile.psd"):
    print("File is in cloud storage!")

# Get file info
info = fs.info("myfile.psd")
print(f"Storage: {info['storage_location']}")
print(f"Size: {info['size']} bytes")

๐ŸŽฏ How It Works

Smart Storage Selection:

  1. Tries primary storage first (Cloudinary or Google Drive)
  2. If full โ†’ automatically uploads to secondary storage
  3. On next upload โ†’ tries primary again (in case you freed up space)

Example Flow:

Primary: Cloudinary, Fallback: Google Drive

Upload 1 โ†’ Cloudinary โœ“
Upload 2 โ†’ Cloudinary โœ“
Upload 3 โ†’ Cloudinary FULL โ†’ Google Drive โœ“ (automatic)
Upload 4 โ†’ Tries Cloudinary again โ†’ Still full โ†’ Google Drive โœ“
[You delete files from Cloudinary]
Upload 5 โ†’ Cloudinary โœ“ (back to primary automatically)

๐Ÿ”ง Configuration

Cloudinary Setup

  1. Sign up at cloudinary.com (free tier: 25GB)
  2. Get your credentials from the dashboard
  3. Run: flash setup

Google Drive Setup

  1. Go to Google Cloud Console
  2. Create a project and enable Google Drive API
  3. Create OAuth 2.0 Client ID (Desktop app)
  4. Run: flash setup-gdrive
  5. First upload will open browser for OAuth authorization

Storage Priority

# Set Cloudinary as primary (default)
flash set-primary cloudinary

# Set Google Drive as primary
flash set-primary gdrive

Configuration is stored in ~/.flash-storage/

๐Ÿ“– Advanced Usage

Batch Upload Script

from pathlib import Path
from flash_storage import flash as fs

# Upload all PSD files
for file in Path("designs").glob("*.psd"):
    result = fs.push(str(file))
    print(f"โœ“ {file.name} โ†’ {result['storage']}")

Conditional Storage

from flash_storage.config import CloudinaryConfig

config = CloudinaryConfig()

# Large files โ†’ Google Drive
file_size = Path("video.mp4").stat().st_size
if file_size > 100 * 1024 * 1024:  # > 100MB
    config.set_primary_storage('gdrive')

# Upload (will use Google Drive as primary)
fs.upload("video.mp4")

Web API Integration

from flask import Flask, request
from flash_storage import flash as fs

@app.route('/upload', methods=['POST'])
def upload():
    file = request.files['file']
    file.save('/tmp/upload')

    result = fs.upload('/tmp/upload')
    return {
        'storage': result['storage'],
        'oid': result['oid'],
        'size': result['size']
    }

๐Ÿ”„ Git LFS Integration

Flash Storage can act as a Git LFS custom transfer agent:

# Initialize in your repo
flash init

# Track files with Git LFS
git lfs track "*.psd"
git lfs track "*.mp4"

# Files automatically upload to your configured storage
git add design.psd
git commit -m "Add design"
git push

๐Ÿ’ก Use Cases

  • Design Teams: Store large Photoshop/Sketch files
  • Video Projects: Manage video files with Git
  • Data Science: Version control datasets and models
  • Game Development: Store game assets and builds
  • Backup Solution: Automatic cloud backup with fallback
  • Build Artifacts: Store compilation outputs

๐Ÿ†“ Free Storage Limits

Service Free Storage Free Bandwidth Notes
Cloudinary 25GB 25GB/month Plus image transformations
Google Drive 15GB Unlimited Shared with Gmail/Photos
Combined 40GB Great for small-medium projects

๐Ÿ“‹ Commands Reference

Command Description
flash setup Configure Cloudinary credentials
flash setup-gdrive Configure Google Drive OAuth
flash set-primary <storage> Set primary storage (cloudinary/gdrive)
flash push <file> Upload file to cloud storage
flash pull <file> Download file from cloud storage
flash upload <file> Upload without replacing local file
flash status Show configuration and storage status
flash init Initialize Git LFS integration

๐Ÿ› ๏ธ Requirements

  • Python 3.8+
  • Git LFS (optional, for Git integration)
  • Cloudinary account (free tier available)
  • Google Cloud project (optional, for Google Drive)

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ”— Links

๐Ÿ™ Credits

Built with:


Made with โšก by the Flash Storage team

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

flash_storage-0.3.0.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

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

flash_storage-0.3.0-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

Details for the file flash_storage-0.3.0.tar.gz.

File metadata

  • Download URL: flash_storage-0.3.0.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for flash_storage-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4323e036730a07281a016f2442fb5399a40ee3fdf7e82b77265282e9515f9e2f
MD5 27f15f304b0cd40aab5ac0fd6f6cdbd1
BLAKE2b-256 3736162ec18070b57b56600003f2ae375af44c706b4ce3651504ebdbc3a65791

See more details on using hashes here.

File details

Details for the file flash_storage-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: flash_storage-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 24.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for flash_storage-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a84fdb09a7fff8a17195bb3fad3eda1e953926f1f4c2d26157340d2fb458fdd9
MD5 9ce35b112cf1cff7769678f5f64ba535
BLAKE2b-256 021c8bb32d82246caa4041db90b7541a6bdf953ba991216adac71233af6de7fd

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