Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharing video to instagram app fails when using the filepath (ANDROID) #574

Closed
albrewot opened this issue Aug 30, 2019 · 5 comments
Closed

Comments

@albrewot
Copy link

Steps to reproduce

  • Download Video to the device using RNFetchBlob or Using Cameraroll
  • Get the file path
  • Use the filepath with Share.shareSingle method to instagram

Expected behaviour

  • Video is shared and loaded to instagram app

Actual behaviour

IMG_20190830_150038

Using RNFetchBlob or CameraRoll filepaths always results in the same behaviour

Code

Using just the filepath from RNFetchBlob

let shareOptions = {
    url: `file://${this.state.files[0].data}`, //FetchBlob file path
    type: `video/${file.extension}`, //file.extension contains the extension of the file
    social: Share.Social.INSTAGRAM
};
await Share.shareSingle(shareOptions);

Using CameraRoll

const saveCameraRoll = await CameraRoll.saveToCameraRoll(
    this.state.files[0].path()
);

const last = await CameraRoll.getPhotos({
    first: 1,
    assetType: "Videos"
});
let shareOptions = {
    url: last.edges[0].node.image.uri,
    type: `video/${file.extension}`,
    social: Share.Social.INSTAGRAM
};
await Share.shareSingle(shareOptions);

I already verified that the paths point to the correct file

example of filepaths given:

RNFetchBlob: /data/user/0/APP_PACKAGE/files/RNFetchBlobTmp_6l8lz5r3hf4ju3ptneklr.mp4

CameraRoll: file:///storage/emulated/0/Pictures/RNFetchBlobTmp_f72tuixtrlqpbrn5hdrnb.mp4

Additional Note

It works fine using base64 as the file but since i'm working with videos and most of the time large size videos (20mb or more) if i use base64 as the file and it's more than 15mb, it makes my app crash or perma-freeze most of the time

Environment

  • React Native version: 0.59.5
  • react-native-share Version: 1.2.1
@albrewot albrewot changed the title Sharing video to instagram app fails when using the filepath Sharing video to instagram app fails when using the filepath (ANDROID) Aug 30, 2019
@jgcmarins
Copy link
Member

jgcmarins commented Aug 31, 2019

is there any other error message besides "video not provided"?

@sergiombravo
Copy link

sergiombravo commented Sep 4, 2019

I found a solution, at least working in my case.

return await RNFetchBlob
      .config({
        // response data will be saved to this path if it has access right.
        fileCache: true,
        path: RNFetchBlob.fs.dirs.DownloadDir + `/${filePath}`
      })
      .fetch('GET', url)

and then share as follow:

const shareOptions = {
  url: `file://${url.path()}`,
  social: Share.Social.INSTAGRAM
};
await Share.shareSingle(shareOptions);

The trick is not to let the file store in your app package but in the download dir instead. I don't know why but I can access and upload any video or picture to instagram ever since I changed the destination. Hope it works for you as well 😄

@albrewot
Copy link
Author

albrewot commented Sep 4, 2019

is there any other error message besides "video not provided"?

I dit a try-catch and it doesn't display any errors

I found a solution, at least working in my case.

return await RNFetchBlob
      .config({
        // response data will be saved to this path if it has access right.
        fileCache: true,
        path: RNFetchBlob.fs.dirs.DownloadDir + `/${filePath}`
      })
      .fetch('GET', url)

and then share as follow:

const shareOptions = {
  url: `file://${url.path()}`,
  social: Share.Social.INSTAGRAM
};
await Share.shareSingle(shareOptions);

The trick is not to let the file store in your app package but in the download dir instead. I don't know why but I can access and upload any video or picture to instagram ever since I changed the destination. Hope it works for you as well 😄

This fix works for me too, thanks.

Maintainers should add this to the readme so people with the same problem can use the library with filepaths too.

@albrewot albrewot closed this as completed Sep 4, 2019
@jgcmarins
Copy link
Member

@albrewot great to know
Do you mind sending a PR updating README?

@patelhari
Copy link

I found a solution, at least working in my case.

return await RNFetchBlob
      .config({
        // response data will be saved to this path if it has access right.
        fileCache: true,
        path: RNFetchBlob.fs.dirs.DownloadDir + `/${filePath}`
      })
      .fetch('GET', url)

and then share as follow:

const shareOptions = {
  url: `file://${url.path()}`,
  social: Share.Social.INSTAGRAM
};
await Share.shareSingle(shareOptions);

The trick is not to let the file store in your app package but in the download dir instead. I don't know why but I can access and upload any video or picture to instagram ever since I changed the destination. Hope it works for you as well 😄

@sergiombravo This is work for me, Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants