Add try catch to heic conversion.
This commit is contained in:
@@ -27,7 +27,7 @@ export async function ConvertHeicFiles(files: Express.Multer.File[]) {
|
|||||||
const convertedFileName = `${
|
const convertedFileName = `${
|
||||||
path.parse(path.basename(file.originalname)).name
|
path.parse(path.basename(file.originalname)).name
|
||||||
}-${Math.floor(Date.now() / 1000)}.jpeg`;
|
}-${Math.floor(Date.now() / 1000)}.jpeg`;
|
||||||
|
try {
|
||||||
await ConvertToJpeg(
|
await ConvertToJpeg(
|
||||||
file.path,
|
file.path,
|
||||||
`${file.destination}/${convertedFileName}`
|
`${file.destination}/${convertedFileName}`
|
||||||
@@ -52,6 +52,14 @@ export async function ConvertHeicFiles(files: Express.Multer.File[]) {
|
|||||||
file.filename = convertedFileName;
|
file.filename = convertedFileName;
|
||||||
file.mimetype = "image/jpeg";
|
file.mimetype = "image/jpeg";
|
||||||
file.path = `${file.destination}/${convertedFileName}`;
|
file.path = `${file.destination}/${convertedFileName}`;
|
||||||
|
} catch (error) {
|
||||||
|
logger.log(
|
||||||
|
"error",
|
||||||
|
`Error converting ${
|
||||||
|
file.filename
|
||||||
|
} image to JPEG from HEIC. ${JSON.stringify(error)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user