Skip to content

Commit 31853fa

Browse files
save file
1 parent 90b171a commit 31853fa

File tree

1 file changed

+9
-8
lines changed
  • blog/25-07-23/streaming-upload-with-fetch/ex

1 file changed

+9
-8
lines changed
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
12
(async()=>{
23

34

45
var url = 'https://localhost:3010/';
56

6-
7+
78
var stream = new ReadableStream({start}).pipeThrough(new TextEncoderStream());
89

910
function start(ctrl){
1011

1112
var count = 1;
1213
var timer = setTimeout(send,1000);
13-
14+
1415

1516
function send(){
1617
console.log('send',count);
@@ -25,18 +26,18 @@
2526
timer = setTimeout(send,1000);
2627

2728
}//send
28-
29+
2930
}//start
3031

31-
32-
33-
32+
33+
34+
3435

3536
var res = await fetch(url,{method:'post',body:stream,duplex:'half'});
3637
var txt = await res.text();
3738
console.log(txt);
38-
39-
39+
40+
4041

4142

4243
})();

0 commit comments

Comments
 (0)