wip(utils): mime type fix
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 7m2s
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 7m2s
This commit is contained in:
@@ -5,10 +5,7 @@ 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.apache.tika.Tika;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.io.*;
|
||||
@@ -82,8 +79,9 @@ public class Utils {
|
||||
try (InputStream is = new BufferedInputStream(new ByteArrayInputStream(input))) {
|
||||
String mimeType;
|
||||
try {
|
||||
mimeType = Magic.getMagicMatch(input, false).getMimeType();
|
||||
} catch (MagicParseException | MagicMatchNotFoundException | MagicException e) {
|
||||
Tika tika = new Tika();
|
||||
mimeType = tika.detect(is);// Magic.getMagicMatch(input, false).getMimeType();
|
||||
} catch (IOException e) {
|
||||
mimeType = URLConnection.guessContentTypeFromStream(is);
|
||||
}
|
||||
String[] detectedExtensions = MimeTypes.findExtensionsByMimeTypes(mimeType, false);
|
||||
|
||||
Reference in New Issue
Block a user