Skip to content

Can't share image! #527

@uraniumreza

Description

@uraniumreza

Steps to reproduce

  1. Install react-native-share
  2. Copy paste this code - https://github.com/react-native-community/react-native-share#example-code
  3. Run; and try this shareImage method -
   const shareImageBase64 = {
      title: 'React native',
      // message: 'Test 1 2 3',
      type: 'image/png',
    };

    const shareImage = (
      fileUrl = 'https://yt3.ggpht.com/a/AGF-l7-BBIcC888A2qYc3rB44rST01IEYDG3uzbU_A=s900-mo-c-c0xffffffff-rj-k-no',
      type = 'image/png',
    ) => {
      let filePath = null;
      // let fileUrlLength = fileUrl.length;
      const configOptions = { fileCache: true };
      RNFetchBlob.config(configOptions)
        .fetch('GET', fileUrl)
        .then((resp) => {
          filePath = resp.path();
          return resp.readFile('base64');
        })
        .then(async (base64Data) => {
          const imageBase64 = `data:${type};base64,${base64Data}`;
          await Share.open({ ...shareImageBase64, url: imageBase64 });
          // console.log(imageBase64, { ...shareImageBase64, url: imageBase64 });
          // remove the image or pdf from device's storage
          await RNFetchBlob.fs.unlink(filePath);
        });
    };

Actual behaviour

Messenger: https://imgur.com/a6IgLTg
Whatsapp: https://imgur.com/E8PAVlh

Environment

  • React Native version: 0.59.9
  • React Native platform + platform version: Android 8.1

react-native-share

Version: npm version 1.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugos: androidstaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions