Im working on a service to download large files. There is a web frontend, that sends a get request, which recieves the file as a stream. I have looked into Streamsaver.js, but i dont want the mitm. Currently using it like this
async function downloadFileFromStream(fileName, streamRef) { // Get the stream from the .NET stream reference const response = await streamRef.stream(); const readableStream = response.getReader(); const fileStream = streamSaver.createWriteStream(fileName); if (window.WritableStream && readableStream.pipeTo) { await readableStream.pipeTo(fileStream); return; } const writer = fileStream.getWriter(); const pump = () => readableStream.read() .then(({ done, value }) => { if (done) { writer.close(); return; } return writer.write(value).then(pump); }); await pump();}// To register the function in the global window object so it can be called from C#window.downloadFileFromStream = downloadFileFromStream;I would like to know if there is a way similar to how i would have done it in C#
psudo-code
Readstream r;Writestream w;r.copyToAsync(w);