Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Support for URI and attaching files from internal storage (SOLVED) #54

Open
ujwal-setlur opened this issue Jan 21, 2017 · 5 comments

Comments

@ujwal-setlur
Copy link

Currently, emails cannot be attached on android unless the attachment is on an external storage. This can be resolved by:

  1. Using a FileProvider such as a react-native-file-provider so that internal files are exposed as contentUri
  2. Code changes in RNMailModule.java to check if the path is a URI or a file path
      import android.webkit.URLUtil;

      if (attachment.hasKey("path") && !attachment.isNull("path")) {
        String path = attachment.getString("path");
        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);
        }
        i.putExtra(Intent.EXTRA_STREAM, p);
      }

I have made these changes in my fork of this repo, and I have also incorporated the pull request
#42 by rusel1989

However, I can't make a pull request because I am using react-native 0.39, and the latest repo is for react-native 0.40.

If anyone needs this functionality, they are welcome to look at my fork

https://github.com/ujwal-setlur/react-native-mail

-ujwal

@ujwal-setlur ujwal-setlur changed the title Attaching files on android without external storage (SOLVED) Android: Support for URI and attaching files from internal storage (SOLVED) Jan 21, 2017
@pallendes
Copy link

Thanks man, that was exactly what I needed

nmorel pushed a commit to Mille-Volts/react-native-mail that referenced this issue Feb 21, 2017
@ujwal-setlur
Copy link
Author

I have issued pull request #71

nmorel pushed a commit to Mille-Volts/react-native-mail that referenced this issue Dec 18, 2017
@cristianoccazinsp
Copy link

Was this ever merged?

@ujwal-setlur
Copy link
Author

Nope

@cristianoccazinsp
Copy link

Such a Tiny fix, @chirag04 can you please implement this. Is this even still maintained?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants