fix(utils): remove JMI for MimeType
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 5m16s

This commit is contained in:
Thibaut Valentin 2025-01-10 15:45:35 +01:00
parent a73c5d0ecb
commit 173f7ececa
2 changed files with 5 additions and 14 deletions

View File

@ -110,12 +110,6 @@
<artifactId>quarkus-websockets</artifactId> <artifactId>quarkus-websockets</artifactId>
</dependency> </dependency>
<dependency>
<groupId>net.sf.jmimemagic</groupId>
<artifactId>jmimemagic</artifactId>
<version>0.1.3</version>
</dependency>
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId> <artifactId>quarkus-smallrye-openapi</artifactId>

View File

@ -5,10 +5,6 @@ import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.Response;
import jodd.net.MimeTypes; import jodd.net.MimeTypes;
import net.sf.jmimemagic.Magic;
import net.sf.jmimemagic.MagicException;
import net.sf.jmimemagic.MagicMatchNotFoundException;
import net.sf.jmimemagic.MagicParseException;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import java.io.*; import java.io.*;
@ -20,8 +16,9 @@ import java.util.Date;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future; import java.util.concurrent.Future;
public class Utils { public class Utils {
private static final org.jboss.logging.Logger LOGGER = Logger.getLogger(Utils.class); private static final Logger LOGGER = Logger.getLogger(Utils.class);
public static int getSaison() { public static int getSaison() {
return getSaison(new Date()); return getSaison(new Date());
@ -79,12 +76,12 @@ public class Utils {
return "OK"; return "OK";
try (InputStream is = new BufferedInputStream(new ByteArrayInputStream(input))) { try (InputStream is = new BufferedInputStream(new ByteArrayInputStream(input))) {
String mimeType; String mimeType = URLConnection.guessContentTypeFromStream(is);
try { /*try {
mimeType = Magic.getMagicMatch(input, false).getMimeType(); mimeType = Magic.getMagicMatch(input, false).getMimeType();
} catch (MagicParseException | MagicMatchNotFoundException | MagicException e) { } catch (MagicParseException | MagicMatchNotFoundException | MagicException e) {
mimeType = URLConnection.guessContentTypeFromStream(is); mimeType = URLConnection.guessContentTypeFromStream(is);
} }*/
String[] detectedExtensions = MimeTypes.findExtensionsByMimeTypes(mimeType, false); String[] detectedExtensions = MimeTypes.findExtensionsByMimeTypes(mimeType, false);
if (detectedExtensions.length == 0) if (detectedExtensions.length == 0)
throw new IOException("Fail to detect file extension for MIME type " + mimeType); throw new IOException("Fail to detect file extension for MIME type " + mimeType);