Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
fix: Having a space in the filename on android no longer causes the f…
Browse files Browse the repository at this point in the history
…iletype to be null
  • Loading branch information
ncgreene authored and Johan-dutoit committed Jan 22, 2020
1 parent bcbde0f commit eab19ca
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions android/src/main/java/com/imagepicker/ImagePickerModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -742,20 +742,26 @@ private String getBase64StringFromFile(String absoluteFilePath) {
private void putExtraFileInfo(@NonNull final String path,
@NonNull final ResponseHelper responseHelper)
{
// size && filename
try {
// size && filename
File f = new File(path);
responseHelper.putDouble("fileSize", f.length());
responseHelper.putString("fileName", f.getName());
// type
String extension = MimeTypeMap.getFileExtensionFromUrl(path);
String fileName = f.getName();
if (extension != "") {
responseHelper.putString("type", MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension));
} else {
int i = fileName.lastIndexOf('.');
if (i > 0) {
extension = fileName.substring(i+1);
responseHelper.putString("type", MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension));
}
}
} catch (Exception e) {
e.printStackTrace();
}

// type
String extension = MimeTypeMap.getFileExtensionFromUrl(path);
if (extension != null) {
responseHelper.putString("type", MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension));
}
}

private void parseOptions(final ReadableMap options) {
Expand Down

0 comments on commit eab19ca

Please sign in to comment.