Alex_A
Alex_A
TtRPC
Created by Alex_A on 6/18/2024 in #❓-help
File upload with formdata
I'm trying to upload a pdf file to R2 and save metadata to my postgres database (both through a trpc procedure). I followed the example in https://github.com/trpc/trpc/tree/next/examples/next-formdata but I get the error copied below. I have been stuck on this for hours and don't know what I'm doing wrong. Envrionment: Next.js 14.2.4 / pnpm Any help would be greatly appreciated!
❌ tRPC failed on presentation.create: [
{
"code": "invalid_type",
"expected": "string",
"received": "undefined",
"path": [
"userId"
],
"message": "Required"
},
{
"code": "custom",
"message": "Input not instance of File",
"fatal": true,
"path": [
"file"
]
}
]
❌ tRPC failed on presentation.create: [
{
"code": "invalid_type",
"expected": "string",
"received": "undefined",
"path": [
"userId"
],
"message": "Required"
},
{
"code": "custom",
"message": "Input not instance of File",
"fatal": true,
"path": [
"file"
]
}
]
My Form code https://github.com/ysqander/trpc_file_upload/blob/main/src/components/FileUploadForm.tsx My procedure: Presentation.create https://github.com/ysqander/trpc_file_upload/blob/main/src/server/api/routers/presentation.ts
5 replies