Dawson
Dawsonβ€’3mo ago

File uploads / downloads

https://github.com/trpc/examples-next-formdata I found this, does this mean it's possible to have file uploads and downloads with trpc now? Does it use chunking or does it put everything into memory.
GitHub
GitHub - trpc/examples-next-formdata
Contribute to trpc/examples-next-formdata development by creating an account on GitHub.
9 Replies
Dawson
DawsonOPβ€’3mo ago
I will need to handle file sizes up to 10gb cc @Shreyas
Nick
Nickβ€’3mo ago
Non-JSON Content Types | tRPC
In addition to JSON-serializable data, tRPC can use FormData, File, and other Binary types as procedure inputs
Nick
Nickβ€’3mo ago
However it's not appropriate to upload potentially large files this way, for that you should do it the "right" way, which means generating an upload link via a host like S3 and having the browser upload directly to it You don't want one file upload overloading your server for all other users, and 10gb risks doing this It may be fine for smaller projects though, just you could end up spending a lot more on hosting in network bandwidth and potentially RAM usage
Dawson
DawsonOPβ€’3mo ago
This has to go directly to the file system it's writing to the local file system inside of a docker container Would it still be "fine" ?
Nick
Nickβ€’3mo ago
Most likely fine if it’s a small use case
Dawson
DawsonOPβ€’3mo ago
It's no different than implementing it myself with something like express, hono, elysia, right?
Nick
Nickβ€’3mo ago
No different, exact same best practices apply
Dawson
DawsonOPβ€’3mo ago
πŸ‘ thank you

Did you find this page helpful?