Closed Urmeli0815 closed 2 years ago
You're close, but there's a missing part:
const reader = file.stream().getReader();
while (true) {
const { done, value } = await reader.read();
if (done) {
console.log('The stream is done.');
break;
}
console.log('Just read a chunk:', value);
}
See my [article](https://web.dev/streams/#the-getreader()-and-read()-methods) for details.
Thank you very much for the fast feedback, I'll try that.
I try the following to read a picked file in chunks:
This doesn't work neither in Edge nor in Firefox.
file.stream()
returns aReadableStream
object but it doesn't seem to have any methods.I also tried to use a variant with
stream.on('data', ...)
but this is alsoundefined
.Am I doing something totally wrong or is this usage just not supported yet by browsers?