file: publicProcedure.input(octetInputParser).mutation(async ({ input }) => { const chunks = []; const FILE_SIZE_LIMIT = 10 * 1024 * 1024; // 10 MB const reader = input.getReader(); while (true) { const { done, value } = await reader.read(); if (done) { break; } const size = Buffer.byteLength(value); chunks.push(value); fileSize += size; if(fileSize > FILE_SIZE_LIMIT){ await reader.cancel('too large'); throw new TRPCError({ code: 'PAYLOAD_TOO_LARGE' }); } } const content = Buffer.concat(chunks).toString('utf-8'); console.log('File: ', content); return { text: 'ACK', data: content, }; }),
POST /api/trpc/upload.file 413 in 426ms
(failed)net::ERR_CONNECTION_RESET