File Uploads

File uploads are handled by UploadThing.

Setup

  1. Create an account on UploadThing.
  2. Create a new app and get your API keys.
  3. Add them to your .env file:
UPLOADTHING_SECRET="sk_live_..."
UPLOADTHING_APP_ID="your-app-id"

Configuration

The UploadThing configuration (router) is located in src/server/uploadthing.ts (or similar, depending on your setup).

Usage

Use the provided components to upload files in your UI.

import { UploadButton } from "@/utils/uploadthing";

export function ImageUploader() {
  return (
    <UploadButton
      endpoint="imageUploader"
      onClientUploadComplete={(res) => {
        console.log("Files: ", res);
        alert("Upload Completed");
      }}
      onUploadError={(error: Error) => {
        alert(`ERROR! ${error.message}`);
      }}
    />
  );
}