Hi Horacio, V8 doesn't implement ReadableStream. You'll probably get better advice by getting in touch with web developers (sadly, I don't have any good pointers to forums where this question would be on-topic, aside from obvious things like StackOverflow).
On Sun, Jan 2, 2022 at 6:13 PM Horacio | Educabot.com < [email protected]> wrote: > Hi everyone, I am trying to upload a file using fetch streams, I need can > calculate the upload progress. > > But on the server I receive an corrupt file of 0 bytes, I really don't > know how to use well the ReadableStreams feature, that is a really new > feature for me. > > Client (Browser) > > const fileReadble = (reader) => new ReadableStream({ > start(controller) { > return pump() > function pump() { > return reader.read().then(({ done, value }) => { > if (done) { > controller.close() > return > } > > controller.enqueue(value) > return pump() > }) > } > } > > const uploadVideo = async (file) => { > const fileReader = file.stream().getReader() > const response = await fetch('http://localhost:3005', { > method: 'POST', > body: fileReadble(fileReader), > }) > > if (!response.ok) { > console.error(`unexpected response ${response.statusText}`) > return > } > } > }) > > Server (Node) > > import http from 'node:http' > import { createWriteStream } from 'node:fs' > > http > .createServer((req) => { > if (req.method !== 'POST') return > req.pipe(createWriteStream('./video.mp4')) > }) > .listen(3005) > > > > -- > -- > v8-dev mailing list > [email protected] > http://groups.google.com/group/v8-dev > --- > You received this message because you are subscribed to the Google Groups > "v8-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/v8-dev/b82deeb7-5f8f-462b-831b-bc640a2a6342n%40googlegroups.com > <https://groups.google.com/d/msgid/v8-dev/b82deeb7-5f8f-462b-831b-bc640a2a6342n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Google Germany GmbH Erika-Mann-Straße 33 80636 München Geschäftsführer: Paul Manicle, Halimah DeLaine Prado Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde. This e-mail is confidential. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person. -- -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev --- You received this message because you are subscribed to the Google Groups "v8-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/CAED6dUDr0uxWCn0pXrjif-vVy3GNW8fAAx6AH7-GxL2f8SmBYw%40mail.gmail.com.
