aws-lambda-libreoffice
aws-lambda-libreoffice copied to clipboard
convertTo fails after upgrade to 7.3.0
I started receiving following error in AWS Lambda in convertTo function after upgrading from 7.2.0 to 7.3.0 recently:
{"errorType":"Error","errorMessage":"Cannot generate PDF preview for ..docx file","stack":["Error: Cannot generate PDF preview for ..docx file"," at convertTo (/lambda/node_modules/@shelf/aws-lambda-libreoffice/lib/convert.js:46:11)"
My code in lambda handler.mjs:
const { fileKey } = JSON.parse(message.body);
if (!fileKey.endsWith('.docx')) {
throw new Error(`File ${fileKey} is not a docx file`);
}
const getObjectResponse = await s3.send(
new GetObjectCommand({
Bucket: process.env.UPLOAD_BUCKET_NAME,
Key: fileKey,
}),
);
const docxFile = `document.docx`;
const outputFilePath = `/tmp/document.pdf`;
await pipeline(
getObjectResponse.Body,
fs.createWriteStream(`/tmp/${docxFile}`),
);
if (!canBeConvertedToPDF(docxFile)) {
throw new Error(`File ${fileKey} cannot be converted to PDF`);
}
await convertTo(docxFile, 'pdf');
await uploadFile(
s3,
outputFilePath,
fileKey.replace('.docx', '.pdf'),
getObjectResponse.Metadata,
);
fs.rmSync(`/tmp/${docxFile}`, { force: true });
fs.rmSync(outputFilePath, { force: true });
Double dots before docx in an error message might be a good hint 🤔
+1 We’ve experienced the same issue. Downgrading to 7.2.0 works.
I am experiencing the same issue. Did you find any solution? Downgrading to 7.2.0 somehow did not work for me.
I am experiencing the same issue. Did you find any solution? Downgrading to 7.2.0 somehow did not work for me.
Check your package-lock.json (and package.json), if you have ^ in front of the version it will take latest available.
In package.json you should have it like this: "@shelf/aws-lambda-libreoffice": "7.2.0"
Still waiting for a real solution 🙏🏻
+1