Multiple email attachments

I have an app that needs to send 2 PDF files via MailComposer, but I’m not certain I’m using it right as I only get 1 of the PDF files on the email. The files are stored in my assets folder.

I’m using Asset.fromModule(require('<filepath>')).downloadAsync(); to download the files on component mount, and then Asset.fromModule(require('<filepath>')).localUri to get the local file uri on button click. I do this for both PDF files and add them for use as described in

This works for one file (the first one I have in the array), but not the second.

I’ve tested this on android with both GMail & Inbox.

Is this a bug or am I missing something?

Hmm, that sounds reasonable. Can you reproduce it on so we can investigate?

Yeah no problem, Here. For some reason it loads the files as js files (I assume because it’s in the bounds of Expo. My project has been detached so it can load pdf files with no issues). You can still see the issue though if you look at the hashes of the two files in the email app, they are both the same.

Maybe try wrapping the function with a try/catch and see if any errors surface, specifically these ones.

I think this is a snack thing :confused:

CC: @aalices :point_left:Module maker

I didn’t see anything when I added a try catch, but I took a look at Logcat and I get this error when I click the button:

Attempt to cast generated internal exception:
    java.lang.ClassCastException: java.lang.String cannot be cast to java.util.ArrayList
        at android.os.BaseBundle.getCharSequenceArrayList(
        at android.os.Bundle.getCharSequenceArrayList(
        at android.content.Intent.getCharSequenceArrayListExtra(
        at android.content.Intent.migrateExtraStreamToClipData(
        at android.content.Intent.migrateExtraStreamToClipData(
        at android.content.ContextWrapper.startActivity(
        at android.content.ContextWrapper.startActivity(
        at java.lang.reflect.Method.invoke(Native Method)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(
        at Method)
        at android.os.Handler.handleCallback(
        at android.os.Handler.dispatchMessage(
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(
        at android.os.Looper.loop(
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$

My Java is a bit rusty, but it looks like the array isn’t being parsed properly at some point in the module.

I’ve started an issue on the Expo repo here

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.