There is no need to use intermediate memory stream 1 - just pass the pdfkit output stream directly to the HTTP download stream.
In my experience, the AWS SDK is rubbish when it comes to working with threads, so I usually use request .
var upload = request({ method: 'PUT', url: 'https://bucket.s3.amazonaws.com/doc.pdf', aws: { bucket: 'bucket', key: ..., secret: ... } }); doc.pipe(upload);
1 - in fact, it is usually undesirable to use a memory stream, because it means buffering the entire object in RAM, which is exactly what threads should avoid!
josh3736
source share