-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
Hi there,
The problem: Androids MimeTypeMap.getFileExtensionFromUrl() could not handle uppercase file extensions, so that downloading of "test.PDF" throws an error while "test.pdf" works.
Solution: Convert filename to lowercase in src/android/DocumentHandler.java in lines 76 & 114.
@@ -75,7 +75,8 @@ public class DocumentHandler extends CordovaPlugin {
InputStream reader = conn.getInputStream();
- String extension = MimeTypeMap.getFileExtensionFromUrl(url);
+ String lowercaseUrl = url.toString().toLowerCase();
+ String extension = MimeTypeMap.getFileExtensionFromUrl(lowercaseUrl);
File f = File.createTempFile(FILE_PREFIX, "." + extension,
null);
// make sure the receiving app can read this file
@@ -108,7 +109,8 @@ public class DocumentHandler extends CordovaPlugin {
private static String getMimeType(String url) {
String mimeType = null;
- String extension = MimeTypeMap.getFileExtensionFromUrl(url);
+ String lowercaseUrl = url.toString().toLowerCase();
+ String extension = MimeTypeMap.getFileExtensionFromUrl(lowercaseUrl);
if (extension != null) {
MimeTypeMap mime = MimeTypeMap.getSingleton();
mimeType = mime.getMimeTypeFromExtension(extension);
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels