Skip to main content

Image Hosting

Multiforum uses Google Cloud Storage (GCS) for hosting uploaded images and files. This guide covers setting up and configuring file storage for your instance.

Overview

The file upload system provides:

  • Signed URLs - Time-limited upload access (15 minutes)
  • File Type Validation - Server and channel-level restrictions
  • Virus Scanning - Optional malware detection
  • Image Moderation - Archive and removal workflows

Setting Up Google Cloud Storage

1. 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

2. Enable the Cloud Storage API

  1. Go to APIs & ServicesLibrary
  2. Search for "Cloud Storage"
  3. Click Enable on the Cloud Storage API

3. Create a Storage Bucket

  1. Go to Cloud StorageBuckets
  2. Click Create Bucket
  3. Configure your bucket:
    • Name: Choose a globally unique name (e.g., your-app-uploads)
    • Location: Choose a region near your users
    • Storage class: Standard (recommended)
    • Access control: Fine-grained
  4. Click Create

4. Configure CORS

For browser uploads to work, configure CORS on your bucket:

[
{
"origin": ["https://your-frontend-domain.com"],
"method": ["GET", "PUT", "POST", "DELETE"],
"responseHeader": ["Content-Type"],
"maxAgeSeconds": 3600
}
]

Apply using gsutil:

gsutil cors set cors.json gs://your-bucket-name

5. Create a Service Account

  1. Go to IAM & AdminService Accounts
  2. Click Create Service Account
  3. Name it (e.g., multiforum-storage)
  4. Grant the Storage Admin role
  5. Create and download a JSON key

6. Encode the Credentials

Base64 encode your service account key:

base64 -i your-service-account-key.json

Save this encoded string for your environment variables.

Environment Variables

Backend

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

Frontend

VITE_GOOGLE_CLOUD_STORAGE_BUCKET=your-bucket-name

File Type Configuration

Server-Level Allowed File Types

Configure default allowed file types in the ServerConfig:

MATCH (s:ServerConfig {serverName: "your-server"})
SET s.allowedFileTypes = [".stl", ".obj", ".zip", ".rar", ".blend", ".png", ".jpg", ".gif"]

Channel-Level Overrides

Individual channels can override server defaults:

  1. Go to Channel SettingsDownloads
  2. Edit the Allowed File Types list
  3. Save changes

Channels can be more restrictive than the server default but not less.

How Uploads Work

Upload Flow

  1. User selects a file to upload
  2. Frontend requests a signed URL from the backend
  3. Backend validates:
    • User authentication
    • File type allowed
    • Channel permissions (if applicable)
  4. Backend generates a time-limited signed URL
  5. Frontend uploads directly to GCS using the signed URL
  6. Frontend notifies backend of successful upload
  7. Backend creates the Image/File record in the database

Signed URL Security

  • URLs expire after 15 minutes
  • Each URL is specific to one file
  • URLs include authentication tokens
  • Direct bucket access is not allowed

Image Features

Image Properties

PropertyDescription
urlThe public URL of the image
altAlternative text for accessibility
captionOptional caption displayed with image
longDescriptionExtended description for screen readers
copyrightCopyright information
hasSensitiveContentFlag for adult/sensitive content
hasSpoilerFlag for spoiler content

Image Scanning

Images can be scanned for malware and inappropriate content:

StatusDescription
PENDINGAwaiting scan
CLEANPassed all scans
INFECTEDMalware detected
SUSPICIOUSFlagged for review
FAILEDScan failed

Image Moderation

Moderators can:

  • Archive - Hide image from public view
  • Permanently Remove - Delete image and purge from storage
  • Report - Create a moderation issue for review

All moderation actions are linked to Issues for audit trails.

Enabling Image Uploads Per Channel

Channels can individually enable or disable image uploads:

  1. Go to Channel Settings
  2. Find Image Uploads Enabled
  3. Toggle on/off
  4. Save changes

Related channel settings:

  • imageUploadsEnabled - Allow direct image uploads
  • markdownImagesEnabled - Allow embedding images via markdown URLs
  • emojiEnabled - Allow emoji reactions

File Versioning

Downloadable files support version history:

  • Each version tracks filename, size, and changelog
  • Users can download previous versions
  • Version history is preserved

Troubleshooting

Upload Failures

  1. Verify GCS bucket exists and is accessible
  2. Check service account has Storage Admin role
  3. Verify CORS configuration
  4. Check file type is allowed
  5. Verify base64 encoding of credentials

CORS Errors

If you see CORS errors in the browser console:

  1. Verify CORS configuration includes your frontend domain
  2. Check that the request method is allowed
  3. Ensure Content-Type header is permitted

Permission Denied

  1. Check user has canUploadFile permission
  2. Verify channel allows uploads (imageUploadsEnabled)
  3. Check file type is in allowed list