From cfdfb8110b6371f70ae39436d82cdcd81cf34e57 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Fri, 22 Aug 2025 12:01:16 -0700 Subject: [PATCH] IO-3340 Change application type on PDFs uploaded via imgproxy to allow inline display. --- server/media/imgproxy-media.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/media/imgproxy-media.js b/server/media/imgproxy-media.js index 646c7cc7d..7a2b1ebfb 100644 --- a/server/media/imgproxy-media.js +++ b/server/media/imgproxy-media.js @@ -44,11 +44,20 @@ const generateSignedUploadUrls = async (req, res) => { for (const filename of filenames) { const key = filename; const client = new S3Client({ region: InstanceRegion() }); - const command = new PutObjectCommand({ + + // Check if filename indicates PDF and set content type accordingly + const isPdf = filename.toLowerCase().endsWith('.pdf'); + const commandParams = { Bucket: imgproxyDestinationBucket, Key: key, StorageClass: "INTELLIGENT_TIERING" - }); + }; + + if (isPdf) { + commandParams.ContentType = "application/pdf"; + } + + const command = new PutObjectCommand(commandParams); const presignedUrl = await getSignedUrl(client, command, { expiresIn: 360 }); signedUrls.push({ filename, presignedUrl, key }); }