I am trying to fetch an image and read it as a stream. Once I have the stream, I want to use this stream to upload the image to a server.
fetch('http://localhost:8080/dist/boo.jpeg')
.then(response => response.body)
.then( readStream => {
fetch('http://localhost:8080/upload', {method: 'post', body: readStream});
});
or
fetch('http://localhost:8080/dist/boo.jpeg')
.then(response => response.body)
.then( readStream => {
var xhr = new XMLHttpRequest();
xhr.open('POST', '/upload', true);
xhr.overrideMimeType('multipart/form-data');
xhr.send(readStream);
});
But the request payload that's sent is a string - [object ReadableStream]