IO-2433 Basic completion webhook, S3 upload, audit trail.

This commit is contained in:
Patrick Fic
2026-02-27 15:44:23 -08:00
parent e25174ff97
commit 52f43a600c
8 changed files with 559 additions and 86 deletions

View File

@@ -94,6 +94,47 @@ const generateSignedUploadUrls = async (req, res) => {
}
};
/**
* Upload a file buffer directly to S3.
* Accepts either `req.file.buffer` (e.g. from multer) or `req.body.buffer` (base64 string).
*/
const uploadFileBuffer = async ({ key, contentType, buffer }) => {
try {
if (!key) {
throw new Error("key is required");
}
if (!buffer) {
throw new Error("buffer is required");
}
const isPdf = key.toLowerCase().endsWith(".pdf");
const client = new S3Client({ region: InstanceRegion() });
const putParams = {
Bucket: imgproxyDestinationBucket,
Key: key,
Body: buffer,
StorageClass: "INTELLIGENT_TIERING"
};
if (contentType) {
putParams.ContentType = contentType;
} else if (isPdf) {
putParams.ContentType = "application/pdf";
}
await client.send(new PutObjectCommand(putParams));
return ({ success: true, key, bucket: imgproxyDestinationBucket });
} catch (error) {
return { success: false, message: error.message, stack: error.stack };
}
};
/**
* Get Thumbnail URLS
* @param req
@@ -500,6 +541,7 @@ const keyStandardize = (doc) => {
module.exports = {
generateSignedUploadUrls,
uploadFileBuffer,
getThumbnailUrls,
getOriginalImageByDocumentId,
downloadFiles,