File Uploads
File uploads are handled by UploadThing.
Setup
- Create an account on UploadThing.
- Create a new app and get your API keys.
- Add them to your
.envfile:
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}`);
}}
/>
);
}