wei
wei
Explore posts from servers
TTCTheo's Typesafe Cult
Created by wei on 5/23/2024 in #questions
Uploadthing multiple upload files
I have 1 feature, where users can upload as many files as they want, how can I upload as many files as possible, without having any limits? If I omit maxFileCount, I can only upload 1 file, is there a way? If there is no way, maybe the solution is to make maxFileCount be 99999 or more
export const ourFileRouter = {
imageUploader: f({ image: { maxFileSize: "4MB", maxFileCount: 10 } })
.input(z.object({ productId: z.string().uuid() }))
.middleware(async ({ input }) => ({ input }))
.onUploadComplete(async ({ metadata: { input: { productId } }, file }) => {
console.info(file.url)
await db.image.create({ data: { productId, url: file.url } });

return { success: true };
}),
} satisfies FileRouter;
export const ourFileRouter = {
imageUploader: f({ image: { maxFileSize: "4MB", maxFileCount: 10 } })
.input(z.object({ productId: z.string().uuid() }))
.middleware(async ({ input }) => ({ input }))
.onUploadComplete(async ({ metadata: { input: { productId } }, file }) => {
console.info(file.url)
await db.image.create({ data: { productId, url: file.url } });

return { success: true };
}),
} satisfies FileRouter;
I've tried reading the documentation, but I can't find it at all, or am I looking at it wrong or something, whatever it is, please help me out.
4 replies