Merged in feature/IO-3340-imgproxy-pdf-contenttype (pull request #2507)
IO-3340 Change application type on PDFs uploaded via imgproxy to allow inline display.
This commit is contained in:
@@ -44,11 +44,20 @@ const generateSignedUploadUrls = async (req, res) => {
|
|||||||
for (const filename of filenames) {
|
for (const filename of filenames) {
|
||||||
const key = filename;
|
const key = filename;
|
||||||
const client = new S3Client({ region: InstanceRegion() });
|
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,
|
Bucket: imgproxyDestinationBucket,
|
||||||
Key: key,
|
Key: key,
|
||||||
StorageClass: "INTELLIGENT_TIERING"
|
StorageClass: "INTELLIGENT_TIERING"
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (isPdf) {
|
||||||
|
commandParams.ContentType = "application/pdf";
|
||||||
|
}
|
||||||
|
|
||||||
|
const command = new PutObjectCommand(commandParams);
|
||||||
const presignedUrl = await getSignedUrl(client, command, { expiresIn: 360 });
|
const presignedUrl = await getSignedUrl(client, command, { expiresIn: 360 });
|
||||||
signedUrls.push({ filename, presignedUrl, key });
|
signedUrls.push({ filename, presignedUrl, key });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user