From ea589b39a5797a6699cc0d1dfedc3ae833b6a36c Mon Sep 17 00:00:00 2001 From: Ian Allen Date: Mon, 29 Jan 2024 11:22:03 -0400 Subject: [PATCH] Fix mimetypes on attachments as some were incorrect. i.e. it could produce the following invalid mime types - text/txt, image/jpg, image/tif Also added htm to the list so that it would not produce application/htm --- .../api/records/attachments/AttachmentsApi.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/services/src/main/java/org/fao/geonet/api/records/attachments/AttachmentsApi.java b/services/src/main/java/org/fao/geonet/api/records/attachments/AttachmentsApi.java index 43f2dcdbf20..908b7f314ae 100644 --- a/services/src/main/java/org/fao/geonet/api/records/attachments/AttachmentsApi.java +++ b/services/src/main/java/org/fao/geonet/api/records/attachments/AttachmentsApi.java @@ -111,15 +111,22 @@ public static String getFileContentType(Path file) throws IOException { case "png": case "gif": case "bmp": + contentType = "image/" + ext; + break; case "tif": case "tiff": + contentType = "image/tiff"; + break; case "jpg": case "jpeg": - contentType = "image/" + ext; + contentType = "image/jpeg"; break; case "txt": + contentType = "text/plain"; + break; + case "htm": case "html": - contentType = "text/" + ext; + contentType = "text/html"; break; default: contentType = "application/" + ext;