File Operations in oRPC
oRPC natively supports standard File and Blob objects. You can even combine files with complex data structures like arrays and objects for upload and download operations.
File Uploads
For uploading files larger than 100 MB, we recommend using a dedicated upload solution or extending the body parser for better performance and reliability, as oRPC does not support chunked or resumable uploads.
File Downloads
For downloading files, we recommend using lazy file libraries like @mjackson/lazy-file or Bun.file to reduce memory usage.
Example
ts
const example = os
.input(z.object({ file: z.file() }))
.output(z.instanceof(File))
.handler(async ({ input }) => {
console.log(input.file.name)
return new File(['Hello World'], 'hello.txt', { type: 'text/plain' })
})