Skip to content

Commit

Permalink
Update to ensure file conversion field is only set when conversion is…
Browse files Browse the repository at this point in the history
… attempted
  • Loading branch information
CEBergin-Vivid committed Apr 13, 2024
1 parent 6daa299 commit 083e38e
Showing 1 changed file with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,23 @@ public SQSBatchResponse handleRequest(SQSEvent sqsEvent, Context context) {
fileExtension = "";
}

Integer fileSize;
boolean fileTooLargeToConvert = false;
if (fileDetailsJson.has("fileSize")) {
fileSize = Integer.parseInt(fileDetailsJson.get("fileSize").toString());
if (fileSize > 10000000) {
fileTooLargeToConvert = true;
GetFileFromWFDMAPI.setImageConversionMetadata(wfdmToken, fileId, versionNumber,
fileDetailsJson, "Image Conversion aborted due to file size");
}
}
Integer fileSize;
boolean fileTooLargeToConvert = false;
if (fileDetailsJson.has("fileSize")) {
fileSize = Integer.parseInt(fileDetailsJson.get("fileSize").toString());
if (fileSize > 10000000) {
fileTooLargeToConvert = true;
}
}
boolean isHeicOrHeif = fileExtension.equals("HEIC") || fileExtension.equals("HEIF");

if (fileTooLargeToConvert && isHeicOrHeif) {
GetFileFromWFDMAPI.setImageConversionMetadata(wfdmToken, fileId, versionNumber,
fileDetailsJson, "Image Conversion aborted due to file size");
}
// if a file has a heic or heif mimetype it needs to be converted by the image
// conversion lambda rather than processed
if ((fileExtension.equals("HEIC") || fileExtension.equals("HEIF")) && !fileTooLargeToConvert) {
GetFileFromWFDMAPI.setImageConversionMetadata(wfdmToken, fileId, versionNumber,
fileDetailsJson, "Image Conversion attempted");
if (isHeicOrHeif && !fileTooLargeToConvert) {
logger.log("\nInfo: File with mimeType of " + mimeType + " calling image conversion lambda");
AWSLambda client = AWSLambdaAsyncClient.builder().withRegion(region).build();
InvokeRequest request = new InvokeRequest();
Expand Down

0 comments on commit 083e38e

Please sign in to comment.