4

I'm trying to upload node stream data to S3 via a signed url, therefore it is vital that the request contains the Content-Length and Content-Type header.

The data I want to upload is provided via a stream

var request = require('request')
var myReadableStream = ...fromSomeTranscoding()..;

myReadableStream.pipe(request({
 method: 'PUT',
 headers : {
  'Content-Length' : ???????
  'Content-Length' : 'image/png'
 }, 
 url: mySignedUploadUrl
}))

As I cannot access the stream length, I can do a workaround by piping it to a file to check its length and then in a second step pipe the file stream, but I guess there must be a better way to achieve this

maxb
  • 486
  • 3
  • 14

0 Answers0