Closed
Description
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.
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
})
}
Metadata
Metadata
Assignees
Labels
No labels