Skip to main content

A Python package that uses GitHub repositories as a database for storing and retrieving data.

Project description

GitHubStorage

A robust and extensible file-based storage system built on GitHub repositories. Supports large file handling with optional compression, encryption, chunking, and version control using commit history. Includes a powerful CLI for ease of use.


✨ Features

  • ✅ Upload, update, read, and delete files in a GitHub repository
  • 📦 Automatic chunking for large files (>50MB)
  • 🗜️ Optional zlib compression
  • 🔐 Optional AES encryption (CTR mode)
  • 🕒 List version history via Git commit logs
  • 🔄 Revert files to previous versions by commit SHA
  • 🖥️ CLI for basic operations

📦 Installation

pip install github-storage

🚀 Getting Started

1. Basic Usage (as a Python library)

from github_storage import GitHubStorage

storage = GitHubStorage(
    token="your_github_token",
    repo_name="username/repo",
    compression=True,
    encryption_key=b"16_or_24_or_32_byte_key"
)

# Upload file
storage.store_file("data/file.txt", "local/path/file.txt")

# Read file
data = storage.read_file("data/file.txt")

# Delete file
storage.delete_file("data/file.txt")

# List versions
versions = storage.list_versions("data/file.txt")

# Revert to specific version
storage.revert_to_version("data/file.txt", sha="commit_sha")

🧪 CLI Usage

python github_storage.py --token <GH_TOKEN> --repo <username/repo> [options] <command>

CLI Arguments

Flag Description
--token Your GitHub Personal Access Token
--repo Target GitHub repo (e.g. user/repo)
--branch Target branch (default: main)
--compression Enable compression (zlib)
--encrypt-key AES encryption key (hex-encoded string)

CLI Commands

store-file

Upload a local file to GitHub.

python github_storage.py --token TOKEN --repo user/repo store-file <repo_path> <local_file_path> [--msg "commit message"]

store-bytes

Store a string as bytes in GitHub.

python github_storage.py --token TOKEN --repo user/repo store-bytes <repo_path> <content_string>

read-file

Read a file and print or save locally.

python github_storage.py --token TOKEN --repo user/repo read-file <repo_path> [--save-to local_path]

delete-file

Delete a file or chunked file.

python github_storage.py --token TOKEN --repo user/repo delete-file <repo_path>

list-versions

List recent commit history for a path.

python github_storage.py --token TOKEN --repo user/repo list-versions <repo_path> [--limit 5]

revert

Revert a file to a previous version using commit SHA.

python github_storage.py --token TOKEN --repo user/repo revert <repo_path> <commit_sha>

🔐 Encryption & Compression

  • Encryption: AES in CTR mode; use 16, 24, or 32 byte key (128, 192, 256 bits).
  • Compression: zlib compression; efficient for text or repetitive binary data.
  • Chunking: Enabled automatically for files larger than chunk_size (default: 50MB).

📁 Chunking Behavior

  • Files larger than chunk_size are split into parts and stored under a .chunks folder in the repo.
  • A manifest.txt file is added to describe the chunked structure.
  • Old single files or chunk folders are automatically cleaned up.

⚠️ Limitations

  • Max GitHub file size: 100MB per file (we use 95MB to be safe).
  • Requires a repo with appropriate write permissions via GitHub token.
  • File size and repo quota limits still apply.

✅ Requirements

Install them with:

pip install PyGithub pycryptodome

🧑‍💻 License

MIT License


📬 Contributing

Pull requests, issues, and suggestions are welcome! Open an issue or fork the project to contribute.


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

github_storage-0.1.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

github_storage-0.1.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file github_storage-0.1.0.tar.gz.

File metadata

  • Download URL: github_storage-0.1.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for github_storage-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b0fedc87547197908a779c62ea49dbf217dd921c472535db4fdb3c2e262bcb77
MD5 b0be8b5360baf5262ad41d7b43e07618
BLAKE2b-256 d8f608cd89ed42d0c88ea3124f81f3364e8926b05af2d9b7a574088c976ca957

See more details on using hashes here.

File details

Details for the file github_storage-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: github_storage-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for github_storage-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a6e8cf516c31950301e948dbf6a861464df7ad6e2a7902b192cafb631daa9ab
MD5 e2efc667d95851370c67007b21be544d
BLAKE2b-256 7c77eb87bf7e8354f398946a4df183df9e70820633298551b4c8c6a413dbf2b9

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