Skip to main content

Google Cloud Storage Setup

Multiforum uses Google Cloud Storage (GCS) for file uploads including images, attachments, and downloads.

Create a Google Cloud Project

  1. Go to Google Cloud Console
  2. Create a new project or select an existing one
  3. Note your Project ID

Enable Cloud Storage API

  1. Go to APIs & Services > Library
  2. Search for "Cloud Storage"
  3. Click Cloud Storage API
  4. Click Enable

Create a Storage Bucket

  1. Go to Cloud Storage > Buckets
  2. Click Create Bucket
  3. Configure the bucket:
    • Name: Choose a globally unique name (e.g., multiforum-uploads-yourname)
    • Location: Select a region close to your deployment
    • Storage class: Standard
    • Access control: Fine-grained
  4. Click Create

Configure CORS

To allow uploads from your frontend, configure CORS:

  1. Create a file named cors.json:
[
{
"origin": ["https://your-frontend-domain.com"],
"method": ["GET", "POST", "PUT", "DELETE"],
"responseHeader": ["Content-Type"],
"maxAgeSeconds": 3600
}
]
  1. Apply the CORS configuration:
gcloud storage buckets update gs://your-bucket-name --cors-file=cors.json

Create a Service Account

  1. Go to IAM & Admin > Service Accounts
  2. Click Create Service Account
  3. Name it (e.g., multiforum-storage)
  4. Click Create and Continue
  5. Grant the Storage Admin role
  6. Click Done

Generate and Encode the Key

  1. Click on your new service account
  2. Go to the Keys tab
  3. Click Add Key > Create new key
  4. Select JSON and click Create
  5. Save the downloaded JSON file securely

Base64 encode the key for use in environment variables:

base64 -i your-key-file.json

Required Environment Variables

Backend (.env)

GCS_BUCKET_NAME=your-bucket-name
GOOGLE_CREDENTIALS_BASE64=your-base64-encoded-credentials

Frontend (.env)

VITE_GOOGLE_CLOUD_STORAGE_BUCKET=your-bucket-name

Next Steps

Continue setting up the other prerequisites: