Adaptations for legacy database importation.

This commit is contained in:
Florian THIERRY
2024-03-21 18:07:33 +01:00
parent 30e5ffa2eb
commit 39663e914d
5 changed files with 12 additions and 11 deletions

View File

@@ -24,7 +24,8 @@ public class MultipartFileConverter {
try {
ALLOWED_MIME_TYPES = List.of(
mimeTypes.forName("image/png"),
mimeTypes.forName("image/jpeg")
mimeTypes.forName("image/jpeg"),
mimeTypes.forName("image/svg+xml")
);
} catch (MimeTypeException exception) {
throw new RuntimeException("An error occurred while loading allowed mime types.", exception);
@@ -48,16 +49,15 @@ public class MultipartFileConverter {
}
private String buildPicturePath(MultipartFile fileContent) {
MimeType fileContentType = extractMimeType(fileContent);
checkMimeTypeIsAllowed(fileContent);
return String.format(
"%s/%s%s",
"%s/%s",
tempPicturesFolderPath,
UUID.randomUUID(),
fileContentType.getExtension()
UUID.randomUUID()
);
}
private MimeType extractMimeType(MultipartFile fileContent) {
private void checkMimeTypeIsAllowed(MultipartFile fileContent) {
MimeType result = null;
try {
result = MimeTypes.getDefaultMimeTypes()
@@ -69,8 +69,6 @@ public class MultipartFileConverter {
if (isNull(result) || !isAllowedMimeType(result)) {
throw new PictureUploadException("Unable to upload the picture because its format is incorrect.");
}
return result;
}
private boolean isAllowedMimeType(MimeType mimeType) {