Integrates Replit Object Storage for persistent file uploads, replacing ephemeral local storage and adding `google-cloud-storage` dependency. Replit-Commit-Author: Agent Replit-Commit-Session-Id: cd9a7d26-a4e5-4215-975c-c59f4ed1f06d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 093bebfc-3b06-4716-8c6a-2dea6a89816d Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/d0a1d46d-d203-4308-bc6a-312ac7c0243b/cd9a7d26-a4e5-4215-975c-c59f4ed1f06d/D3TcT39
3.4 KiB
3.4 KiB
🗄️ Object Storage Setup Guide
Problem: Images Disappearing After a Few Hours
Your website was saving uploaded images to the local filesystem (static/images/), which is ephemeral storage in Replit. This means files get automatically deleted after a few hours.
Solution: Replit Object Storage (Persistent Storage)
I've updated your website to use Replit Object Storage, which is built on Google Cloud Storage and provides permanent file storage.
📋 Setup Instructions (Required)
Step 1: Create an Object Storage Bucket
- Open the Tools panel in your Replit workspace (left sidebar)
- Click on Object Storage
- Click "Create a Bucket"
- Give it a name (e.g.,
ftc-team-images) - Click Create
Step 2: Set Environment Variable
- Go to the Secrets tab in your Replit workspace (lock icon in left sidebar)
- Add a new secret:
- Key:
OBJECT_STORAGE_BUCKET - Value: Your bucket name (e.g.,
ftc-team-images)
- Key:
- Click Add Secret
Step 3: Restart the Server
- Stop the Flask server if it's running
- Start it again (or let it auto-restart)
✅ How It Works Now
Automatic Upload to Persistent Storage
All file uploads now go to Object Storage instead of local storage:
- Member/Mentor Photos →
members/folder in your bucket - Competition Images →
competitions/folder - Sponsor Logos →
sponsors/folder
Full Image URLs
Images are now stored as full Google Cloud Storage URLs like:
https://storage.googleapis.com/ftc-team-images/members/abc123.jpg
These URLs are:
- ✅ Permanent - Never get deleted
- ✅ Fast - Served directly from Google's CDN
- ✅ Public - Accessible from anywhere on the web
- ✅ Reliable - Backed by Google Cloud infrastructure
🔧 Code Changes Made
New Files:
object_storage.py- Object storage service moduleOBJECT_STORAGE_SETUP.md- This guide
Updated Files:
app.py- All upload routes now use object storageadd_member()- Member/mentor imagesupdate_member()- Member/mentor updatesadd_competition()- Competition imagesedit_competition()- Competition image updatesadd_sponsor()- Sponsor logos
Updated Dependencies:
- Added
google-cloud-storagepackage
🚀 Testing
After setup, test by:
- Go to
/admin/login(password:techturb123) - Upload a new member photo or competition image
- Check that the image displays correctly
- Wait a few hours - the image should still be there!
🔒 Security Notes
- Object storage is authenticated automatically via Replit's infrastructure
- All uploaded files are made publicly accessible (required for website images)
- Files are organized into folders for easy management
- Each file gets a unique UUID to prevent naming conflicts
⚠️ Important: Fallback Mode
If you haven't set up object storage yet, the website will still work using local storage (ephemeral):
- You'll see a warning in the console:
"Warning: Object Storage not configured" - Files will still be saved but will disappear after a few hours
- Set up object storage ASAP to make uploads permanent!
📚 Additional Resources
Need Help? If you have any issues with setup, check the console logs for error messages.