Tired of the complexity of S3? UploadSignal simplifies the process with a secure and straightforward solution designed specifically for developers. From initiating uploads to server-side handling, we've got everything you need covered.
You manage the authentication on your system, while we take care of the file transfer.
export const fileRouter = {
imageUploader: f({ maxFileSize: "4MB" })
.middleware(async ({ req }) => {
// This code runs on your server before upload
const user = await auth(req);
// Throw to block uploading
if (!user)
throw new UploadThingError("Unauthorized");
// Return metadata to client
return { userId: user.id };
})
.onUploadComplete(async ({ metadata, file }) => {
// ...
}),
} satisfies FileRouter;
<UploadButton
endpoint="imageUploader" // Typesafe btw
onClientUploadComplete={(response) => ...}
onUploadError={(error) => ...}
/>