Skip to content

File Operations in oRPC

oRPC natively supports file uploads and downloads using standard File and Blob objects, requiring no additional configuration.

TIP

For files larger than 100 MB, we recommend using a dedicated upload solution or extending the body parser for better performance and reliability, because oRPC does not support chunked or resumable uploads.

Validation

oRPC uses standard File and Blob objects for file operations.

ts
const 
example
=
os
.
input
(
z
.
object
({
file
:
z
.
file
() }))
.
output
(
z
.
object
({
file
:
z
.
instanceof
(
File
) }))
.
handler
(async ({
input
}) => {
console
.
log
(
input
.
file
.
name
)
return {
file
:
input
.
file
}
})

INFO

For handling large files more efficiently, especially streaming downloads, consider using lazy-file or similar libraries that allow you to work with files in a streaming manner.

Released under the MIT License.