Tellay ⚡
Tellay ⚡
TTCTheo's Typesafe Cult
Created by Tellay ⚡ on 5/28/2024 in #questions
Uploading zip/rar files
I'm trying to upload the zip/rar files, I already have the pdfs and images upload working but I can't upload the zip/rar files. Behavior: It lets me select the zip but nothing else happens. My core file:
import { validateRequest } from "@/lib/lucia";
import { createUploadthing, type FileRouter } from "uploadthing/next";
import { UploadThingError } from "uploadthing/server";

const f = createUploadthing();

export const ourFileRouter = {
imageUploader: f({
image: { maxFileSize: "4MB" },
pdf: { maxFileSize: "8MB" },
"application/zip": { maxFileSize: "8MB" },
})
.middleware(async ({ req }) => {
const { session } = await validateRequest();
if (!session) throw new UploadThingError("Unauthorized");

return { userId: session.userId };
})
.onUploadComplete(async ({ metadata, file }) => {
return { uploadedBy: metadata.userId, file };
}),
} satisfies FileRouter;

export type OurFileRouter = typeof ourFileRouter;
import { validateRequest } from "@/lib/lucia";
import { createUploadthing, type FileRouter } from "uploadthing/next";
import { UploadThingError } from "uploadthing/server";

const f = createUploadthing();

export const ourFileRouter = {
imageUploader: f({
image: { maxFileSize: "4MB" },
pdf: { maxFileSize: "8MB" },
"application/zip": { maxFileSize: "8MB" },
})
.middleware(async ({ req }) => {
const { session } = await validateRequest();
if (!session) throw new UploadThingError("Unauthorized");

return { userId: session.userId };
})
.onUploadComplete(async ({ metadata, file }) => {
return { uploadedBy: metadata.userId, file };
}),
} satisfies FileRouter;

export type OurFileRouter = typeof ourFileRouter;
2 replies