File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import { auth } from "@clerk/nextjs/server";
22import { createUploadthing , type FileRouter } from "uploadthing/next" ;
33import { UploadThingError } from "uploadthing/server" ;
44
5+ import * as mutations from "~/server/db/mutations" ;
6+
57const f = createUploadthing ( ) ;
68
79export const ourFileRouter = {
@@ -18,6 +20,9 @@ export const ourFileRouter = {
1820 console . log ( "Upload complete for userId:" , metadata . userId ) ;
1921 console . log ( "file url" , file . ufsUrl ) ;
2022
23+ const uploadedFile = { ...file , parent : 0 } ;
24+ await mutations . createFile ( uploadedFile , metadata . userId ) ;
25+
2126 return { uploadedBy : metadata . userId } ;
2227 } ) ,
2328} satisfies FileRouter ;
Original file line number Diff line number Diff line change 1+ import { db } from "~/server/db" ;
2+ import { type File , files_table as filesSchema } from "~/server/db/schema" ;
3+
4+ export function createFile ( file : Omit < File , "id" > , _userId : string ) {
5+ return db . insert ( filesSchema ) . values ( file ) ;
6+ }
You can’t perform that action at this time.
0 commit comments