Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heic image converter lambda #108

Merged
merged 10 commits into from
Apr 13, 2024
Merged
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
Loading