import { router, publicProcedure, protectedProcedure } from "../trpc";
import { z } from "zod";
import JSZip from "jszip";
const MAX_FILE_SIZE = 5000000;
const ACCEPTED_IMAGE_TYPES = ["image/jpeg", "image/jpg", "image/png", "image/webp"];
const imageSchema = z.object({
image: z
.any()
.refine((file) => file?.size <= MAX_FILE_SIZE, 'Maximum file size is 50MB')
.refine((file) => ACCEPTED_IMAGE_TYPES.includes(file?.type), 'Unsupported file type')
})
export const uploadRouter = router({
upload: protectedProcedure
.input(imageSchema.array().min(5).max(10))
.mutation(({ ctx, input }) => {
const zip = new JSZip();
const remoteZips = input.map((image) => {
// ERROR HERE
zip.file(image.name, image)
});
})
})
import { router, publicProcedure, protectedProcedure } from "../trpc";
import { z } from "zod";
import JSZip from "jszip";
const MAX_FILE_SIZE = 5000000;
const ACCEPTED_IMAGE_TYPES = ["image/jpeg", "image/jpg", "image/png", "image/webp"];
const imageSchema = z.object({
image: z
.any()
.refine((file) => file?.size <= MAX_FILE_SIZE, 'Maximum file size is 50MB')
.refine((file) => ACCEPTED_IMAGE_TYPES.includes(file?.type), 'Unsupported file type')
})
export const uploadRouter = router({
upload: protectedProcedure
.input(imageSchema.array().min(5).max(10))
.mutation(({ ctx, input }) => {
const zip = new JSZip();
const remoteZips = input.map((image) => {
// ERROR HERE
zip.file(image.name, image)
});
})
})