React-native-share: How to share local image as url??

Created on 5 Oct 2017  路  3Comments  路  Source: react-native-share/react-native-share

When I try :

let shareOptions = {
            title: "React Native",
            message: "Hola mundo",
            url: 'file://' + './Rick_Sanchez.png',
            //url: IMG,
            type: 'image/png',
            subject: "Share Link" //  for email
        };

This is the result:

screenshot_20171005-111835

This also happens when I upload a .gif

Also the message and title don't work on android!!!

Most helpful comment

Hi there! I use react-native-fs to get the base64-encoded version of an image then pass to react-native-share:

RNFS.readFile(RNFS.DocumentDirectoryPath + '/previews/test.jpg', 'base64').then((image) => {
  Share.open({
    url: 'data:image/jpeg;base64,' + image,
    type: 'image/jpeg'
  }).catch((err) => {
    // Handle error
    // ...
  });
});

Hopefully that helps. Good luck!

All 3 comments

Hi there! I use react-native-fs to get the base64-encoded version of an image then pass to react-native-share:

RNFS.readFile(RNFS.DocumentDirectoryPath + '/previews/test.jpg', 'base64').then((image) => {
  Share.open({
    url: 'data:image/jpeg;base64,' + image,
    type: 'image/jpeg'
  }).catch((err) => {
    // Handle error
    // ...
  });
});

Hopefully that helps. Good luck!

Hi there, closing issues assuming latest releases must have addressed this issue. Please feel free to open it again thanks 馃槂

Does this solution work on Android, @coryjb ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MbF-Sathya picture MbF-Sathya  路  4Comments

kunalnagar picture kunalnagar  路  3Comments

saifkamaal picture saifkamaal  路  3Comments

byk04712 picture byk04712  路  3Comments

crivera picture crivera  路  3Comments