Skip to content

File upload

Pass a path, eberly reads the file and builds the multipart form (avatar.test.ts):

const avatarPath = fileURLToPath(new URL('./fixtures/avatar.png', import.meta.url))
const res = await alice.users.uploadAvatar({ body: { file: avatarPath } })
const user = res.assert(201).body
expect(user.avatarUrl).toBe(`/avatars/${user.id}.png`)

A file can also be a URL, { path, name?, type? }, { content, name }, Blob or File.

A backend may expect other field names for an array of files (oRPC wants files[0], files[1]): see files in the config reference and the oRPC recipe.

Privacy-friendly analytics, no cookies.