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.URLConnection;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@ -77,12 +78,14 @@ public class Utils {
|
||||
|
||||
try (InputStream is = new BufferedInputStream(new ByteArrayInputStream(input))) {
|
||||
String mimeType = URLConnection.guessContentTypeFromStream(is);
|
||||
System.out.println(mimeType);
|
||||
/*try {
|
||||
mimeType = Magic.getMagicMatch(input, false).getMimeType();
|
||||
} catch (MagicParseException | MagicMatchNotFoundException | MagicException e) {
|
||||
mimeType = URLConnection.guessContentTypeFromStream(is);
|
||||
}*/
|
||||
String[] detectedExtensions = MimeTypes.findExtensionsByMimeTypes(mimeType, false);
|
||||
System.out.println(Arrays.toString(detectedExtensions));
|
||||
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