Skip to content

Commit

Permalink
fix(libre-office): correct file naming to preserve order
Browse files Browse the repository at this point in the history
  • Loading branch information
cherfia committed Dec 12, 2024
1 parent fa8261d commit b4bb45f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/libre-office/utils/libre-office.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,18 @@ export class LibreOfficeUtils {
files: PathLikeOrReadStream[],
data: FormData
) {
const paddingLength = String(files.length).length + 1;
await Promise.all(
files.map(async (file, key) => {
files.map(async (file, index) => {
const fileInfo = await this.getFileInfo(file);
if (!LIBRE_OFFICE_EXTENSIONS.includes(fileInfo.ext)) {
throw new Error(`${fileInfo.ext} is not supported`);
}
data.append('files', fileInfo.data, `${key}.${fileInfo.ext}`);
const filename = `file${String(index + 1).padStart(
paddingLength,
'0'
)}.${fileInfo.ext}`;
data.append('files', fileInfo.data, filename);
})
);
}
Expand Down

0 comments on commit b4bb45f

Please sign in to comment.