Skip to content

Commit

Permalink
fix(pdf-engines): 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 93faa76 commit fa8261d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pdf-engines/utils/pdf-engines.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ export class PDFEnginesUtils {
files: PathLikeOrReadStream[],
data: FormData
) {
const paddingLength = String(files.length).length + 1;
await Promise.all(
files.map(async (file, key) => {
const filename = `file${key}.pdf`;
files.map(async (file, index) => {
const filename = `file${String(index + 1).padStart(paddingLength, '0')}.pdf`;
if (Buffer.isBuffer(file)) {
data.append('files', file, filename);
} else if (file instanceof ReadStream) {
Expand Down

0 comments on commit fa8261d

Please sign in to comment.