I have a stream of data and want to hit a certain endpoint I don't want to store the data locally to find the content length as I need to pass the content length as the headers property. So what are possible ways to get the content length?
(readStream) => {
const requestOptions = {
url: 'https://url.com',
method: 'PUT',
headers: {
'Content-Type': 'application/octet-stream',
'Content-Length': length,
},
body: readStream
}
request(requestOptions, function (error, response, body) {
});
}