]> nmode's Git Repositories - signal-cli/blobdiff - lib/src/main/java/org/asamk/signal/manager/util/StickerUtils.java
Reformat files
[signal-cli] / lib / src / main / java / org / asamk / signal / manager / util / StickerUtils.java
index f3825cc4aced54a096d98192f155dcc3957fd8cd..d017f0a57b60b06f8f9ad39b0b8f16f317a39004 100644 (file)
@@ -12,7 +12,6 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.Optional;
 import java.util.zip.ZipFile;
@@ -101,7 +100,9 @@ public class StickerUtils {
     }
 
     private static Pair<InputStream, Long> getInputStreamAndLength(
-            final String rootPath, final ZipFile zip, final String subfile
+            final String rootPath,
+            final ZipFile zip,
+            final String subfile
     ) throws IOException {
         if (zip != null) {
             final var entry = zip.getEntry(subfile);
@@ -113,16 +114,18 @@ public class StickerUtils {
     }
 
     private static String getContentType(
-            final String rootPath, final ZipFile zip, final String subfile
+            final String rootPath,
+            final ZipFile zip,
+            final String subfile
     ) throws IOException {
         if (zip != null) {
             final var entry = zip.getEntry(subfile);
             try (InputStream bufferedStream = new BufferedInputStream(zip.getInputStream(entry))) {
-                return URLConnection.guessContentTypeFromStream(bufferedStream);
+                return MimeUtils.getStreamMimeType(bufferedStream).orElse(null);
             }
         } else {
             final var file = new File(rootPath, subfile);
-            return Utils.getFileMimeType(file, null);
+            return MimeUtils.getFileMimeType(file).orElse(null);
         }
     }
 }