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;
}
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);
}
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);
}
}
}