I tried to push a QR code of SVG to S3 from my node application.
I believe I should be uploading a Buffer to S3. Whenever I try to inspect the qrResult, I don't get to see one anywhere.
Guess I'm fundamentally poor with the concept of writeStreams, and how should I pipe the data to an S3 upload, I am not able to resolve this, tried several times. This is what I am using there:
let fileName = 'qrCode'
let qrCode = Qr.image('The ultimate test', { type: 'svg' });
let output = fs.createWriteStream(fileName)
let qrResult = qrCode.pipe(output)
let s3bucket = new Aws.S3({
accessKeyId: env.AWS_ACCESS_KEY
secretAccessKey: env.AWS_SECRET,
Bucket: env.S3_BUCKET_NAME,
});
let params = {
Bucket: env.S3_BUCKET_NAME,
Key: fileName,
Body: qrResult,
};
s3bucket.upload(params, function (err, qrResult) {
if (err) {
console.log('error in callback');
console.log(err);
}
console.log('success');
console.log(qrResult);
});
Can anyone help me with this?