Files
FTCWebsite/OBJECT_STORAGE_SETUP.md
abhiramtx f4d32ff9ee Ensure uploaded images are permanently stored in object storage
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
2025-11-13 05:36:58 +00:00

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

  1. Open the Tools panel in your Replit workspace (left sidebar)
  2. Click on Object Storage
  3. Click "Create a Bucket"
  4. Give it a name (e.g., ftc-team-images)
  5. Click Create

Step 2: Set Environment Variable

  1. Go to the Secrets tab in your Replit workspace (lock icon in left sidebar)
  2. Add a new secret:
    • Key: OBJECT_STORAGE_BUCKET
    • Value: Your bucket name (e.g., ftc-team-images)
  3. Click Add Secret

Step 3: Restart the Server

  1. Stop the Flask server if it's running
  2. 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 Photosmembers/ folder in your bucket
  • Competition Imagescompetitions/ folder
  • Sponsor Logossponsors/ 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 module
  • OBJECT_STORAGE_SETUP.md - This guide

Updated Files:

  • app.py - All upload routes now use object storage
    • add_member() - Member/mentor images
    • update_member() - Member/mentor updates
    • add_competition() - Competition images
    • edit_competition() - Competition image updates
    • add_sponsor() - Sponsor logos

Updated Dependencies:

  • Added google-cloud-storage package

🚀 Testing

After setup, test by:

  1. Go to /admin/login (password: techturb123)
  2. Upload a new member photo or competition image
  3. Check that the image displays correctly
  4. 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.