Filedownload through tRPC

I try to get a Filedownload working through tRPC. Currently i'm using useMutation in the Frontend. If invoked, the mutation leads to a fs.readFileSync and converts it to an ascii String. I think this is not ideal since in the Frontend i use useEffect to look after the Change of the mutation to then create a blob and a link to the Blob to download the file. Ideally i would like to use fs.createReadStream to send the Data as chunks and directly download the Data instead of waiting to recieve it and then have an instant download on my hand. I'm very open to ideas since finding little Documentation for that problem.
2 Replies
JacobMGEvans
JacobMGEvans2y ago
Need to have repro or something to be able to help. https://stackoverflow.com/help/minimal-reproducible-example
Stack Overflow
How to create a Minimal, Reproducible Example - Help Center
Stack Overflow | The World’s Largest Online Community for Developers
NoelHuibers
NoelHuibers2y ago
I made a CodeSandbox for this: https://codesandbox.io/p/github/NoelHuibers/test/example Notice that CodeSandbox does not let you download files in their sandbox. Files that are important: pages/index & server/router/download
CodeSandbox
CodeSandbox is an online editor tailored for web applications.
Want results from more Discord servers?
Add your server