transientDocument Id generating API does not work when filestream is passed from S3
If I create a readFileStream from local directory then I am able to upload template and get transient Id but If done the same by fetching the uploaded docx file in S3 it doesn't work. I am getting the file Stream using the below code and it doesn't work.
async function getFileStream() {
// configuring the AWS environment
AWS.config.update({
accessKeyId: process.env.AWS_ACCESS_KEY,
secretAccessKey: process.env.AWS_SECRET_KEY,
});
// initialize s3
const s3 = new AWS.S3();
const file = s3.getObject({ Bucket: 'bucket', Key: 'key.docx' }).createReadStream();
const pass = new stream.PassThrough();
stream.pipeline(
file,
pass,
(err) => {
if (err) {
console.error(err);
}
},
);
return file;
}
But when I implemented it directly like below then it works perfectly.
const file = fs.createReadStream(file.path);
return file;
There is no error in the above case but the response never comes until 120 seconds and then it throws timeout error.
