3.4 KiB
3.4 KiB
Sharey B2 Migration Summary
What Changed
Your Sharey application has been successfully modified to use Backblaze B2 cloud storage instead of local file storage. Here are the key changes:
🔄 Core Changes
-
Storage Backend:
- Removed local file storage (
uploads/andpastes/folders) - Added Backblaze B2 cloud storage integration
- Files and pastes now stored in B2 bucket
- Removed local file storage (
-
Dependencies Added:
b2sdk: Official Backblaze B2 SDKpython-dotenv: Environment variable management
-
Configuration:
- Added
.envfile support for B2 credentials - Added connection validation and error handling
- Added health check endpoint
- Added
📁 New Files Created
requirements.txt- Python dependencies.env.example- Environment templatesetup.py- Automated setup script (Python-based)test_b2.py- B2 connection testing utilityDEPLOYMENT.md- Production deployment guide- Updated
.gitignore- Improved git ignore rules - Updated
README.md- Comprehensive setup instructions
🔧 Modified Functions
-
File Upload (
/api/upload):- Now uploads files directly to B2 bucket under
files/prefix - Returns B2 direct download URLs
- Better error handling
- Now uploads files directly to B2 bucket under
-
File Serving (
/files/<file_id>):- Now redirects to B2 download URLs
- No longer serves files locally
-
Paste Creation (
/api/paste):- Stores paste content in B2 under
pastes/prefix - UTF-8 encoding support
- Stores paste content in B2 under
-
Paste Viewing (
/pastes/<paste_id>and/pastes/raw/<paste_id>):- Downloads paste content from B2
- Maintains same user interface
🏗️ Bucket Organization
Your B2 bucket will be organized as:
your-bucket/
├── files/ # Uploaded files (images, documents, etc.)
│ ├── abc123.jpg
│ ├── def456.pdf
│ └── ...
└── pastes/ # Text pastes
├── ghi789.txt
├── jkl012.txt
└── ...
Next Steps
-
Get B2 Credentials:
- Sign up at Backblaze B2
- Create application key and bucket
- Note down: Key ID, Application Key, Bucket Name
-
Configure Environment:
cp .env.example .env # Edit .env with your B2 credentials -
Install Dependencies:
python setup.py # or manually: pip install -r requirements.txt -
Test Configuration:
python test_b2.py -
Run Application:
python app.py
Benefits of B2 Storage
- ✅ Scalable: No local disk space limitations
- ✅ Reliable: Built-in redundancy and backups
- ✅ Cost-effective: Pay only for what you use
- ✅ Global CDN: Fast downloads worldwide
- ✅ Secure: Encrypted storage with access controls
- ✅ Maintenance-free: No local file management needed
Migration Notes
- Existing local files/pastes will remain in local folders
- New uploads will go to B2
- Old URLs will break (files are now served from B2)
- No data migration script provided (manual migration needed if desired)
- B2 bucket should be set to "Public" for file sharing to work properly
Support
If you encounter issues:
- Run
python test_b2.pyto test your configuration - Check the health endpoint:
http://localhost:8866/health - Verify B2 bucket permissions and settings
- Ensure your .env file has correct credentials