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.

Is it possible to share multiple images at once?

See original GitHub issue

I’ve been using this module to share images, one at a time. I’m using RNFS.readFile to get base64 data of the image, and setting the appropriate MIME type manually. It’s working fine.

But, I would like to share multiple images with a single Share.open call. Is this possible?

Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
eominecommented, Aug 21, 2017

@Kampeone I had to use RNFS (react-native-fs) and: 1- Download the image file to the device; 2- Read the downloaded file; 3- Pass the file contents as a base64 string to react-native-share.

import RNFS from 'react-native-fs';
import Share from 'react-native-share';

share(file, fileName) {
  const localFile = `${RNFS.DocumentDirectoryPath}/${fileName}`;
  const options = {
    fromUrl: file,
    toFile: localFile,
  };
  RNFS.downloadFile(options).promise
    .then(() => this.share1(localFile))
    .catch(this.onError);
}
share1(localFile) {
  RNFS.readFile(localFile, 'base64')
    .then(base64 => {
      const mimeType = Utils.getMimeType(localFile);
      Share.open({
        type: mimeType,
        url: `data:${mimeType};base64,${base64}`,
      });
    });
}

Images could be JPG or PNG, so I had a Utils.getMimeType method to get the correct MIME type. It just read the file extension and returned the proper MIME type string (image/jpeg or image/png) accordingly.

0reactions
mariusgabcommented, Aug 25, 2017

@eomine Thanks, it worked!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Send Lots of Photos to Someone | FileWhopper Blog
Want to share a lot of photos with your friends? Check out this article to find the best way to share photos online...
Read more >
How to Share Single Or Multiple Photos On Android Phone
1. Open the Photos or Gallery app on your Android Phone or tablet. ; 2. Tap on the Photo that you would like...
Read more >
The Various Ways to Share Large Photo Batches with Family ...
One of the most popular methods for sharing large amounts of photos online is by using a file-sharing site. Sites like HighTail (formally...
Read more >
3 Apps That Let You Send Multiple Photos for Free - Lifewire
3 Apps That Let You Send Multiple Photos for Free · Use these apps to privately send photos to anyone · Great for...
Read more >
How to share multiple photos in one Instagram post - CNET
From the home screen, hit the + icon at the bottom of the screen. · Tap the first image you want to add....
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