Skip to content

Downloading and attaching an image on Android #93

@ptsimpso

Description

@ptsimpso

Providing a remote URL for image attachment works fine on iOS, but fails to attach an image on Android. I am attempting to use react-native-fetch-blob to download the image first, however when I try to provide the downloaded image file url, I get a "exposed beyond app through clipdata.item.geturi()" error.

Does anybody know how to properly download an image on Android and then provide it as an attachment?

My code:

const res = await RNFetchBlob.config({
                fileCache: true,
                appendExt: 'png',
              })
                .fetch('GET', shareImage);
              fileUrl = 'file://' + res.path();

const attachment = {
            url: fileUrl,
            iosType: 'public.png',
            iosFilename: 'Image.png',
            androidType: 'image/*'
          };

          SendSMS.send({
            body: shareText,
            recipients: [],
            successTypes: ['sent', 'queued'],
            allowAndroidSendWithoutReadPermission: true,
            attachment: attachment
          }, (completed, cancelled, error) => {
            console.log('SMS Callback: completed: ' + completed + ' cancelled: ' + cancelled + 'error: ' + error);
          });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions