diff --git a/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java b/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java index 10e4462c..4f189c3c 100644 --- a/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java +++ b/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java @@ -175,8 +175,13 @@ class DownloadFileThread extends Thread { // Check if we should get the file ext from the MIME type if (getFileExtFromMIME) { - String fileExt = URLConnection.guessContentTypeFromStream(bis).replaceAll("image/", ""); - saveAs = new File(saveAs.toString() + "." + fileExt); + String fileExt = URLConnection.guessContentTypeFromStream(bis); + if (fileExt != null) { + fileExt = fileExt.replaceAll("image/", ""); + saveAs = new File(saveAs.toString() + "." + fileExt); + } else { + logger.error("Was unable to get content type from stream"); + } } // If we're resuming a download we append data to the existing file if (statusCode == 206) {