Skip to content

Instantly share code, notes, and snippets.

@dsine-de
dsine-de / fetch-api-stream-upload.js
Last active May 16, 2024 08:21
Fetch API Stream Upload
let bytesUploaded = 0;
const transformStream = new TransformStream({
transform(chunk, controller) {
console.log('progress:', bytesUploaded / blob.size);
bytesUploaded += chunk.byteLength;
controller.enqueue(chunk);
},
flush() {