Merge pull request #794 from cyian-1756/getFileExtFromMIME

Now prints error when ripme can't get a files type from the stream
This commit is contained in:
cyian-1756 2018-07-10 17:27:49 -04:00 committed by GitHub
commit df6897504e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,8 +175,13 @@ class DownloadFileThread extends Thread {
// Check if we should get the file ext from the MIME type // Check if we should get the file ext from the MIME type
if (getFileExtFromMIME) { if (getFileExtFromMIME) {
String fileExt = URLConnection.guessContentTypeFromStream(bis).replaceAll("image/", ""); String fileExt = URLConnection.guessContentTypeFromStream(bis);
saveAs = new File(saveAs.toString() + "." + fileExt); 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 we're resuming a download we append data to the existing file
if (statusCode == 206) { if (statusCode == 206) {