Uploadthing error "An error occured while parsing input/output" when I try to upload with Insomnia

Hello, This is the error I get:
{
"message": "An error occured while parsing input/output"
}
{
"message": "An error occured while parsing input/output"
}
This is my fastify:
server.register(fastifyMultipart)

server.register(createRouteHandler, {
router: uploadRouter
})
server.register(fastifyMultipart)

server.register(createRouteHandler, {
router: uploadRouter
})
This is my Uploadthing:
import { createUploadthing, type FileRouter } from 'uploadthing/fastify'

const f = createUploadthing()

export const uploadRouter = {
imageUploader: f({
image: {
maxFileSize: '4MB',
maxFileCount: 4
}
}).onUploadComplete((data) => {
console.log('upload completed', data)
})
} satisfies FileRouter

export type OurFileRouter = typeof uploadRouter
import { createUploadthing, type FileRouter } from 'uploadthing/fastify'

const f = createUploadthing()

export const uploadRouter = {
imageUploader: f({
image: {
maxFileSize: '4MB',
maxFileCount: 4
}
}).onUploadComplete((data) => {
console.log('upload completed', data)
})
} satisfies FileRouter

export type OurFileRouter = typeof uploadRouter
No description
13 Replies
markr
markr2mo ago
What is in the multipart tab? The request should just have a JSON body also the actionType of multipart-complete is just for letting the server know that a multipart upload has completed. you are probably looking for the upload action type which, given ocrrect input, will return a presigned url / array of presigned urls for your client to use to upload the file
DINO
DINO2mo ago
Thank you very much for your help. I changed to upload and it same error
No description
No description
DINO
DINO2mo ago
@markr sorry for the ping, but I don't have anyone else to help me with this. I really appreciate it.
phisch
phisch2w ago
@DINO did you ever figure out what caused this?
DINO
DINO2w ago
No, I stopped using it after I got no help. I uploaded the files using the SDK straight up.
markr
markr2w ago
It appears in this case, the cause is that the user is attempting to send file data to the /api/uploadthing route, which is not how it works, thus input is not parsed correctly. The /api/uploadthing route should be used to request presigned urls, which you can then upload the files with.
phisch
phisch2w ago
GitHub
uploadthing/examples/backend-adapters/server/src/elysia.ts at main ...
File uploads for modern web devs. Contribute to pingdotgg/uploadthing development by creating an account on GitHub.
markr
markr2w ago
Yes? The endpoint should exist, but you don't use it for actually uploading the files directly. The endpoint only accepts application/json, not multipart/form-data
phisch
phisch2w ago
The example vue client shows how to use the UploadButton and DropZone components, and how they are hooked up to the backend. And those upload to that. https://github.com/pingdotgg/uploadthing/blob/main/examples/backend-adapters/client-vue/src/App.vue
GitHub
uploadthing/examples/backend-adapters/client-vue/src/App.vue at mai...
File uploads for modern web devs. Contribute to pingdotgg/uploadthing development by creating an account on GitHub.
phisch
phisch2w ago
But the request that is sent to that backend API actually just contains a json with file information. But maybe those are two different issues?
markr
markr2w ago
They don’t upload to it. They use it to request presigned urls which are then used by the component to upload the files on client. The files themselves never go to the server.
phisch
phisch2w ago
Okay, but even if they don't send the file directly, it still fails for me with that error. From the example code.
markr
markr2w ago
Yeah, I think your issue is different than the one DINO faced here. Even though it is the same error.
Want results from more Discord servers?
Add your server