Skip to content

Commit

Permalink
Heic image converter lambda (#108)
Browse files Browse the repository at this point in the history
* Add image converter lambda js file

* Update to add delete of original file, some checks for file responses, and comments

* add image converter lambda name to main.tf script for the wfdm file index initializer, add a call to the file index initializer to call the image conversion lambda for heic files

* Remove commented out code

* Change access of fileId from event since the lambda is no longer pulling from a queue

* remove delete from file conversion lambda as the file will now be replacing itself as a version update once the API is updated

* Adding notifier if image conversion is attempted or aborterd due to file size

* Update to ensure file conversion field is only set when conversion is attempted
  • Loading branch information
CEBergin-Vivid committed Apr 13, 2024
1 parent 871dddf commit c72a9d8
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 c72a9d8

Please sign in to comment.