Merge pull request 'fix(utils): remove JMI for MimeType' (#3) from dev into master
Reviewed-on: https://git.poupouche.fr/Thibaut/ffsaf-site/pulls/3
This commit is contained in:
commit
b070bb5767
@ -11,6 +11,7 @@ import java.io.*;
|
|||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@ -77,12 +78,14 @@ public class Utils {
|
|||||||
|
|
||||||
try (InputStream is = new BufferedInputStream(new ByteArrayInputStream(input))) {
|
try (InputStream is = new BufferedInputStream(new ByteArrayInputStream(input))) {
|
||||||
String mimeType = URLConnection.guessContentTypeFromStream(is);
|
String mimeType = URLConnection.guessContentTypeFromStream(is);
|
||||||
|
System.out.println(mimeType);
|
||||||
/*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);
|
||||||
|
System.out.println(Arrays.toString(detectedExtensions));
|
||||||
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);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user