Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

downloading file-stream from browser get request

$
0
0

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);

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>