Skip to content

Commit

Permalink
Fix: Upload the merged PDF to Pinata
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksonkasi1 committed Oct 17, 2024
1 parent 3b5dbb5 commit 7da5d53
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { Router, Request, Response } from "express";
// ** import third-party lib
import multer from "multer";

// ** import config
import { env } from "../../config/env";

// ** import utils
import { uploadMultiplePdfFiles, removeFiles } from "../../utils/file-utils";
import { mergePdfFiles, convertToColorMode, applyPassword } from "../../utils/pdf-utils";
Expand All @@ -19,6 +22,9 @@ const upload = multer({
fileFilter: uploadMultiplePdfFiles,
});


const groupId = env.PINATA_PUBLIC_GROUP_ID; // Pinata public group id, to get file without signed URL

/**
* POST /api/upload-opt/merge-and-upload
* Upload multiple PDFs, optionally apply password protection and grayscale/CMYK conversion,
Expand Down Expand Up @@ -62,7 +68,7 @@ router.post("/merge-and-upload", (req: Request, res: Response) => {
}

// Upload the merged PDF to Pinata
const response = await uploadFileToPinata(outputFile.outputPath, outputFile.outputFilename);
const response = await uploadFileToPinata(outputFile.outputPath, outputFile.outputFilename, groupId, 'application/pdf');

// Clean up both original and merged files
const filePathsToRemove = files.map((file: Express.Multer.File) => file.path).concat([outputFile.outputPath]);
Expand Down

0 comments on commit 7da5d53

Please sign in to comment.