Skip to content

Commit aac17a2

Browse files
name ordered files
1 parent ef92dae commit aac17a2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/app/api/ai-upload/route.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export async function POST(req: Request) {
126126
return;
127127
}
128128

129-
const mergedPdfBytes = await CreatePDF(files);
129+
const mergedPdfBytes = await CreatePDF(orderedFiles);
130130
[public_id_cloudinary, finalUrl] = await uploadPDFFile(
131131
mergedPdfBytes,
132132
uploadPreset,
@@ -204,12 +204,13 @@ async function uploadFile(
204204
}
205205
}
206206

207-
async function CreatePDF(files: File[]) {
207+
async function CreatePDF(orderedFiles: File[]) {
208208
const pdfDoc = await PDFDocument.create();
209209
//sort files using name. Later remove to see if u can without names
210-
const orderedFiles = Array.from(files).sort((a, b) => {
211-
return a.name.localeCompare(b.name);
212-
});
210+
// moved to main function
211+
// const orderedFiles = Array.from(files).sort((a, b) => {
212+
// return a.name.localeCompare(b.name);
213+
// });
213214

214215
for (const file of orderedFiles) {
215216
const fileBlob = new Blob([file]);

0 commit comments

Comments
 (0)