Initial commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { createUploadthing, type FileRouter } from "uploadthing/next";
|
||||
import { auth } from "@/auth";
|
||||
|
||||
const f = createUploadthing();
|
||||
|
||||
export const uploadRouter = {
|
||||
/** Full-resolution video upload (mp4, mov) */
|
||||
versionVideo: f({
|
||||
video: {
|
||||
maxFileSize: "2GB",
|
||||
maxFileCount: 1,
|
||||
},
|
||||
})
|
||||
.middleware(async () => {
|
||||
const session = await auth();
|
||||
if (!session?.user) throw new Error("Unauthorized");
|
||||
return { userId: session.user.id };
|
||||
})
|
||||
.onUploadComplete(async ({ metadata, file }) => {
|
||||
return { uploadedBy: metadata.userId, url: file.url };
|
||||
}),
|
||||
|
||||
/** Thumbnail / poster image upload */
|
||||
versionThumbnail: f({
|
||||
image: {
|
||||
maxFileSize: "4MB",
|
||||
maxFileCount: 1,
|
||||
},
|
||||
})
|
||||
.middleware(async () => {
|
||||
const session = await auth();
|
||||
if (!session?.user) throw new Error("Unauthorized");
|
||||
return { userId: session.user.id };
|
||||
})
|
||||
.onUploadComplete(async ({ metadata, file }) => {
|
||||
return { uploadedBy: metadata.userId, url: file.url };
|
||||
}),
|
||||
} satisfies FileRouter;
|
||||
|
||||
export type OurFileRouter = typeof uploadRouter;
|
||||
Reference in New Issue
Block a user