From ca57b843820570b837b92cebbcc20d021ab788c8 Mon Sep 17 00:00:00 2001 From: Nicolas Morel Date: Tue, 21 Feb 2017 16:22:18 +0100 Subject: [PATCH] Add support for internal storage attachment Issue https://github.com/chirag04/react-native-mail/issues/54 --- .../main/java/com/chirag/RNMail/RNMailModule.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/chirag/RNMail/RNMailModule.java b/android/src/main/java/com/chirag/RNMail/RNMailModule.java index 9407871..0f38d6c 100644 --- a/android/src/main/java/com/chirag/RNMail/RNMailModule.java +++ b/android/src/main/java/com/chirag/RNMail/RNMailModule.java @@ -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; @@ -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); } }