Adaptations for legacy database importation.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user