Hi Five team,
I believe I may have found a bug in five.addAttachment() when attaching an XLSX file as a Base64 Data URI.
Issue summary
When using:
five.addAttachment(fileData, fileName);
with:
- a valid XLSX Base64 Data URI
- a filename ending with
.xlsx
the attachment received by email does not preserve the supplied filename.
Expected filename
Honoraires-BBC-14.xlsx
Actual filename received
Honoraires-BBC-14.xlsx_591c3e7d2491de3fbc5301417a8ea799.octet-stream
The attached file itself is valid, but users cannot open it directly from their email because the .xlsx extension has effectively been replaced by .octet-stream. They must first download the attachment and manually rename it, which is a major issue for my application because users expect to be able to open the Excel attachment directly from their email.
Code used
const fileName = item.nom ? item.nom : (context.Subject + ".xlsx");
const fileData =
"data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64," +
excelData.base64;
five.log("fileName = " + fileName);
five.log("fileData prefix = " + fileData.substring(0,120));
five.addAttachment(fileData, fileName);
Additional information
I have already verified the following:
excelData.base64starts withUEsDB..., which is the expected ZIP signature for a valid XLSX file.- The generated XLSX file is valid and opens correctly after manually renaming it to
.xlsx. - The filename passed to
five.addAttachment()is correct immediately before the call. - The Data URI uses the official XLSX MIME type:
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet - PDF attachments generated with
five.toDataURL('application/pdf', ...)preserve their filename correctly. - The issue appears to affect XLSX attachments only (or possibly manually-created Data URI attachments).
I could not find any documentation indicating that XLSX attachments are unsupported.
Is this a known limitation or a bug?
If needed, I can provide access to a deployed application that reproduces the issue.
Thank you!
Jean
Note: This post was written with the assistance of an AI to help describe the issue clearly in English. However, all observations, tests, logs, and code snippets are from my own application.