diff --git a/wfdm-file-index-initializer/src/main/java/ca/bc/gov/nrs/wfdm/wfdm_file_index_initializer/ProcessSQSMessage.java b/wfdm-file-index-initializer/src/main/java/ca/bc/gov/nrs/wfdm/wfdm_file_index_initializer/ProcessSQSMessage.java index e520b58..eb52952 100644 --- a/wfdm-file-index-initializer/src/main/java/ca/bc/gov/nrs/wfdm/wfdm_file_index_initializer/ProcessSQSMessage.java +++ b/wfdm-file-index-initializer/src/main/java/ca/bc/gov/nrs/wfdm/wfdm_file_index_initializer/ProcessSQSMessage.java @@ -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();