T
TanStack5w ago
old-apricot

Receiving a file in a server function

Initially, I tried to use zod-form-data to be the validator:
.validator((data: unknown) => schema.parse(data))
.validator((data: unknown) => schema.parse(data))
this would be rejected that the type of the file param is not File. I see the same issue when using FormData:
.validator((data) => {
if (input instanceof FormData) {
const blob = input.get("blob");
const id = input.get("id");
const kind = input.get("kind");
})
.validator((data) => {
if (input instanceof FormData) {
const blob = input.get("blob");
const id = input.get("id");
const kind = input.get("kind");
})
when i console.log(typeof blob), I get string.
1 Reply
old-apricot
old-apricotOP5w ago
figured this out -- you must pass method: POST when dealing with files on server functions.

Did you find this page helpful?