- From: Conrad Irwin <notifications@github.com>
- Date: Fri, 11 Aug 2017 11:18:58 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Friday, 11 August 2017 18:19:19 UTC
I'd like progress events on uploads. I think this should work according to the current spec, but it doesn't seem to work in practice, as I'm not sure how to tell the fetch "how much stream" it should read. ```javascript function upload (url, blob, onUploadProgress) { let progress = 0 let readableByteStream = new ReadableStream({ type: 'byte' pull: function (controller) { onUploadProgress({todo: blob.size, done: progress}) let nextProgress = progress + controller.desiredSize controller.enqueue(@blob.slice(progress, nextProgress)) progress = nextProgress } }) return fetch(url, { mode: 'cors' method: 'POST' headers: {'Content-Type': blob.type} body: readableByteStream }) } ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/fetch/issues/577
Received on Friday, 11 August 2017 18:19:19 UTC