Commit a63baa53 authored by Leonardo Aramaki's avatar Leonardo Aramaki

When file extension is empty set the mime-type to be application/octet-stream...

When file extension is empty set the mime-type to be application/octet-stream - arbitrary binary data
parent 78369367
...@@ -49,7 +49,11 @@ fun Uri.getMimeType(context: Context): String { ...@@ -49,7 +49,11 @@ fun Uri.getMimeType(context: Context): String {
context.contentResolver.getType(this) context.contentResolver.getType(this)
} else { } else {
val fileExtension = MimeTypeMap.getFileExtensionFromUrl(toString()) val fileExtension = MimeTypeMap.getFileExtensionFromUrl(toString())
MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension.toLowerCase()) if (fileExtension != null) {
MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension.toLowerCase())
} else {
"application/octet-stream"
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment