Merge pull request 'fix(utils): remove JMI for MimeType' (#2) from dev into master
Reviewed-on: https://git.poupouche.fr/Thibaut/ffsaf-site/pulls/2
This commit is contained in:
commit
110e514dac
6
pom.xml
6
pom.xml
@ -110,12 +110,6 @@
|
||||
<artifactId>quarkus-websockets</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.jmimemagic</groupId>
|
||||
<artifactId>jmimemagic</artifactId>
|
||||
<version>0.1.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-smallrye-openapi</artifactId>
|
||||
|
||||
@ -5,10 +5,6 @@ import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
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 java.io.*;
|
||||
@ -20,8 +16,9 @@ import java.util.Date;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
|
||||
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() {
|
||||
return getSaison(new Date());
|
||||
@ -79,12 +76,12 @@ public class Utils {
|
||||
return "OK";
|
||||
|
||||
try (InputStream is = new BufferedInputStream(new ByteArrayInputStream(input))) {
|
||||
String mimeType;
|
||||
try {
|
||||
String mimeType = URLConnection.guessContentTypeFromStream(is);
|
||||
/*try {
|
||||
mimeType = Magic.getMagicMatch(input, false).getMimeType();
|
||||
} catch (MagicParseException | MagicMatchNotFoundException | MagicException e) {
|
||||
mimeType = URLConnection.guessContentTypeFromStream(is);
|
||||
}
|
||||
}*/
|
||||
String[] detectedExtensions = MimeTypes.findExtensionsByMimeTypes(mimeType, false);
|
||||
if (detectedExtensions.length == 0)
|
||||
throw new IOException("Fail to detect file extension for MIME type " + mimeType);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user