A Python script that uploads a folder of images to Cloudflare R2 and Google Drive. Photos are automatically numbered (1.jpg, 2.jpg, etc.) and uploaded to R2 in the format photo_collections/{collection_name}/{number}.jpg.
-
Clone this repository
-
Install dependencies using uv:
uv sync
-
Set up configuration:
- Copy
constants.py.exampletoconstants.py - Fill in your Cloudflare R2 credentials:
R2_ENDPOINT_URL: Your R2 endpoint (e.g.,https://abc123.r2.cloudflarestorage.com)R2_ACCESS_KEY_ID: Your R2 access keyR2_SECRET_ACCESS_KEY: Your R2 secret keyR2_BUCKET_NAME: Your R2 bucket name
- Copy
-
For Google Drive (optional):
- Get a
credentials.jsonfile from the Google Cloud Platform - Enable the Google Drive API for your project
- Get a
uv run photo_manager.py folderNameThe script will:
- Ask if you want to upload to Cloudflare R2
- Ask if you want to upload to Google Drive
- Process all JPG files in the specified folder, numbering them sequentially
- Upload to your selected destinations
First-time Google Drive usage: A browser will open to authenticate with Google Drive. This creates a token.pickle file for future use.
Resumability: The script checks for existing files and skips them, so you can safely restart interrupted uploads.
Run the test suite to verify everything is working correctly:
uv run python -m unittest test_photo_manager -v