Closed SakuraYou closed 7 months ago
$start.onclick = () => { const url = 'xxxx', // a 2gb size file const fileStream = streamSaver.createWriteStream('cat.mp4') fetch(url).then(res => { const readableStream = res.body // more optimized if (window.WritableStream && readableStream.pipeTo) { return readableStream.pipeTo(fileStream) .then(() => console.log('done writing')) } window.writer = fileStream.getWriter() const reader = res.body.getReader() const pump = () => reader.read() .then(res => res.done ? writer.close() : writer.write(res.value).then(pump)) pump() }) }
Browser?
yes!
I mean... what browser & version are you using to cause a crash?
Sorry, it’s my problem. A colleague here rewrote the fetch method, causing memory accumulation.