question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sharing base64 on facebook on android m+

See original GitHub issue

Sharing a base64 image on facebook is not working currently, The share window opens without any image. Heres the test code:

let shareImageBase64 = {
  url: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAMAAAANIilAAAAAYFBMVEUAAAAAQIAAWpwAX5kAX5gAX5gAX5gAXJwAXpgAWZ8AX5gAXaIAX5gAXpkAVaoAX5gAXJsAX5gAX5gAYJkAYJkAXpoAX5gAX5gAX5kAXpcAX5kAX5gAX5gAX5YAXpoAYJijtTrqAAAAIHRSTlMABFis4vv/JL0o4QvSegbnQPx8UHWwj4OUgo7Px061qCrcMv8AAAB0SURBVEjH7dK3DoAwDEVRqum9BwL//5dIscQEEjFiCPhubziTbVkc98dsx/V8UGnbIIQjXRvFQMZJCnScAR3nxQNcIqrqRqWHW8Qd6cY94oGER8STMVioZsQLLnEXw1mMr5OqFdGGS378wxgzZvwO5jiz2wFnjxABOufdfQAAAABJRU5ErkJggg==", //this.props.screen,
  social: "facebook"
};

Share.shareSingle(shareImageBase64);

Here is the output on Android:

 SHARE SINGLE METHOD
 com.facebook.katana
 INSTALLED
 java.io.FileNotFoundException: /storage/emulated/0/Download/1500128174012.png (Permission denied)
     at java.io.FileOutputStream.open(Native Method)
     at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
     at java.io.FileOutputStream.<init>(FileOutputStream.java:169)
     at cl.json.ShareFile.getURI(ShareFile.java:120)
     at cl.json.social.ShareIntent.open(ShareIntent.java:49)
     at cl.json.social.SingleShareIntent.open(SingleShareIntent.java:41)
     at cl.json.social.FacebookShare.open(FacebookShare.java:22)
     at cl.json.RNShareModule.shareSingle(RNShareModule.java:63)
     at java.lang.reflect.Method.invoke(Native Method)
     at com.facebook.react.cxxbridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
     at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
     at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
     at android.os.Handler.handleCallback(Handler.java:751)
     at android.os.Handler.dispatchMessage(Handler.java:95)
     at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
     at android.os.Looper.loop(Looper.java:154)
     at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:199)
     at java.lang.Thread.run(Thread.java:761)

I guess you save base64 to a file and then sharing the file. However on android M+ we need write external storage permission for that. So actually when I’m opening this issue, I just answered my question, but still better the issue stays here for others. Maybe this could be added into document or include permission request before sharing base64 for ease of use.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8

github_iconTop GitHub Comments

3reactions
sibeliuscommented, Apr 19, 2018
const allowedStorage = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
      {
        title: 'Permissão para compartihar imagem',
        message: 'App precisa de sua permissão para utilizar o armazenamento de seu celular.',
      },
    );

ask for persmissions

1reaction
murat-mehmetcommented, Jul 15, 2017

yep! it worked. this will save my day at least. wish it could work with share.shareSingle as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

sharing base64 on facebook on android m+ #142 - GitHub
Sharing a base64 image on facebook is not working currently, The share window opens without any image. Heres the test code: let shareImageBase64 ......
Read more >
React Native sharing base64 image is not working
I am using react-native-share but using the shareSingle option like this: Share.shareSingle({ message:'I just added a new outfit to my album ...
Read more >
Sharing Content with Intents | CodePath Android Cliffnotes
Intents allow us to communicate data between Android apps and implicit intents can ... Facebook doesn't work well with normal sharing intents when...
Read more >
Share Dialog - Meta for Developers - Facebook
The Share dialog gives people the ability to publish an individual story to their timeline, a friend's timeline, a group, or in a...
Read more >
Meta Privacy Policy - How Meta collects and uses user data
Learn how we collect, use and share user data to support Facebook, Instagram, Messenger and more. Use tools to manage your privacy preferences....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found