Skip to content

Commit

Permalink
Add support for internal storage attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Morel committed Feb 21, 2017
1 parent 563d90a commit ca57b84
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions android/src/main/java/com/chirag/RNMail/RNMailModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.webkit.URLUtil;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
Expand Down Expand Up @@ -86,8 +87,16 @@ public void mail(ReadableMap options, Callback callback) {
ReadableMap attachment = attachments.getMap(j);
if (attachment.hasKey("path") && !attachment.isNull("path")) {
String path = attachment.getString("path");
File file = new File(path);
Uri p = Uri.fromFile(file);
Uri p;
// Check for valid URI
if (URLUtil.isValidUrl(path)) {
p = Uri.parse(path);
}
// Else this is an absolute file path
else {
File file = new File(path);
p = Uri.fromFile(file);
}
uris.add(p);
}
}
Expand Down

0 comments on commit ca57b84

Please sign in to comment.