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_sizeare split into parts and stored under a.chunksfolder in the repo. - A
manifest.txtfile 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
- Python 3.6+
PyGithubpycryptodome
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.
Metadata
Release files for github-storage 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| github_storage-0.1.0.tar.gz | 10.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| github_storage-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.7 kB
Release files / github_storage-0.1.0.tar.gz
| Download URL | github_storage-0.1.0.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b0fedc87547197908a779c62ea49dbf217dd921c472535db4fdb3c2e262bcb77
|
|
BLAKE2b-256 checksum How to use checksums |
d8f608cd89ed42d0c88ea3124f81f3364e8926b05af2d9b7a574088c976ca957
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / github_storage-0.1.0-py3-none-any.whl
| Download URL | github_storage-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a6e8cf516c31950301e948dbf6a861464df7ad6e2a7902b192cafb631daa9ab
|
|
BLAKE2b-256 checksum How to use checksums |
7c77eb87bf7e8354f398946a4df183df9e70820633298551b4c8c6a413dbf2b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|