Creator
Storage

Storage Overview

File storage with Cloudflare R2 or Supabase Storage.

Creator supports two storage providers for file uploads. Set your choice via environment variable:

NEXT_PUBLIC_STORAGE_SERVICE="r2"  # or "supabase"

You only need to configure the provider you pick. The storage service in lib/services/storage-service.ts selects the right one at runtime.

Public API

import { uploadFile, deleteFile, getKeyFromUrl } from "@/lib/services/storage-service";
FunctionDescription
uploadFile(buffer, key, contentType)Upload a file, returns { url, key }
deleteFile(key)Delete a file by its storage key
getKeyFromUrl(url)Extract the storage key from a public URL

Current usage

Storage is currently used for user avatar uploads via POST /api/user/avatar. The endpoint validates file size (max 3MB) and type (JPG, PNG only), uploads the file, and updates the user's image field.

On this page

We use cookies to ensure you get the best experience on our website. For more information on how we use cookies, please see our cookie policy.