application/octet-stream response
Im refactoring my old backend to trpc so far it was a pleasure and fairly straight forward process ❤️ Im amazed.
Now I faced the issue with the files. I have one endpoint from external API that returns the data as
application/octet-stream
. (csv/xlsx) Can I handle this with trpc?? Probably I can't pass directly the response from the API throught trpc procedure and read it on client. I was thinking if I could parse response on backend (read it as text) and send text to client and download it? Would that work? Is it some kind of security? One problem could occur if the file would be big I guess??1 Reply
Sending large amounts of data via tRPC, especially binary, isn't really recommended right now. It's a downside and is being actively investigated by the team
The best way is to use a file host, push the data to it, generate a readonly URI, and send the URI to the client. Then vice-versa, generate a write-uri and ask the client to upload to it then ping the API to grab the data
This is actually a best practice even on REST APIs, but the flexibility to choose is definitely something the team wants to work on