This guide will help you set up Google Cloud Storage for your SREF Library images.
✅ Free Tier: 5GB storage + 1GB egress/month
✅ Global CDN: Fast worldwide delivery
✅ Reliable: Google's enterprise infrastructure
✅ Scalable: Grows with your needs
✅ Cost Effective: Pay only for what you use
- Google Account - Sign up at cloud.google.com
- Python 3.7+ - Already installed
- Google Cloud SDK (optional) - For easier setup
- Go to Google Cloud Console
- Click "Select a project" → "New Project"
- Name:
sref-library(or your preferred name) - Click "Create"
- In your project, go to "APIs & Services" → "Library"
- Search for "Cloud Storage API"
- Click "Enable"
- Go to "Cloud Storage" → "Buckets"
- Click "Create bucket"
- Bucket name:
sref-library-images(must be globally unique) - Location: Choose closest to your users (e.g.,
us-central1) - Storage class:
Standard - Access control:
Uniform - Click "Create"
- Go to "IAM & Admin" → "Service Accounts"
- Click "Create Service Account"
- Name:
sref-uploader - Description:
Service account for uploading SREF images - Click "Create and Continue"
- Role:
Storage Admin - Click "Continue" → "Done"
- Click on the service account → "Keys" tab
- Click "Add Key" → "Create new key"
- Choose "JSON" → "Create"
- Download the JSON file and save it securely
- Install Google Cloud SDK: cloud.google.com/sdk/docs/install
- Run:
gcloud auth application-default login - This uses your user credentials automatically
# Install Google Cloud Storage SDK
pip install google-cloud-storageCreate a .env file:
# For Service Account (Option A)
GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/service-account-key.json
GCS_BUCKET_NAME=sref-library-images
# For User Authentication (Option B) - just set bucket name
GCS_BUCKET_NAME=sref-library-imagesYour images need to be publicly accessible. Run the provided script:
# Edit the script first to set your bucket name
nano make_bucket_public.sh
# Then run it
./make_bucket_public.shOr manually:
- Go to your bucket in Cloud Console
- Click "Permissions" tab
- Click "Add Principal"
- New principal:
allUsers - Role:
Storage Object Viewer - Click "Save"
# Upload all images to Google Cloud Storage
python upload_to_gcs.pyThis will:
- Upload all 2,320 JPG files to your GCS bucket
- Create
gcs_image_mapping.jsonwith URL mappings - Show progress for each image
# Deploy your app
vercel --prod- App uses local images from
static/images/ - Fast local development
- App uses GCS URLs from
gcs_image_mapping.json - Images served from Google's global CDN
- Super fast worldwide delivery
- Local:
static/images/101236067_01.jpg - GCS:
https://storage.googleapis.com/sref-library-images/sref-images/101236067_01.jpg
sref-library/
├── app.py # Updated to use GCS URLs
├── gcs_image_mapping.json # Generated by upload script
├── upload_to_gcs.py # Upload script
├── make_bucket_public.sh # Bucket permissions script
├── .env # Your credentials (keep secret!)
├── static/
│ ├── css/
│ ├── js/
│ └── images/ # Excluded from deployment
└── sref_analysis/ # Search index (included)
- Verify bucket name is correct
- Check you're in the right Google Cloud project
- Ensure bucket exists in the console
- Check service account has
Storage Adminrole - Verify JSON key file path is correct
- For user auth, run
gcloud auth application-default login
- Ensure bucket is publicly readable
- Check the public access policy
- Verify image URLs in the mapping file
- Check your internet connection
- Verify Google Cloud credentials
- Ensure you have sufficient quota
For your 46MB of images:
Free Tier (First 12 months):
- Storage: 5GB free (your 46MB fits easily)
- Egress: 1GB/month free
- Total: $0/month
After Free Tier:
- Storage: ~$0.01/month (46MB × $0.020/GB)
- Egress: ~$0.15/month (1GB × $0.12/GB)
- Total: ~$0.16/month
✅ Solves Size Issue - Images no longer count toward 250MB limit
✅ Global CDN - Fast image delivery worldwide
✅ Cost Effective - Stays within free tier for months
✅ Reliable - Google's enterprise infrastructure
✅ Scalable - Grows with your needs
✅ Secure - Fine-grained access control
- Run the upload script
- Test locally to ensure images load
- Deploy to Vercel
- Verify images work in production
Your app will now have fast, globally distributed image delivery from Google Cloud Storage! 🚀
For even faster delivery, you can add Google Cloud CDN:
- Go to "Network Services" → "Cloud CDN"
- Create a load balancer with your GCS bucket as backend
- This provides additional caching and optimization
This is optional but recommended for high-traffic applications.