React-native: [iOs] Can not get stats of photo/video

Created on 28 Mar 2019  路  5Comments  路  Source: facebook/react-native

馃悰 Bug Report

Since I upgraded react-native from 0.57.4 to 0.59.1 I cannot get stats from iOs files:
Error: failed to stat path ph://9F983DBA-EC35-42B8-8773-B597CF782EDD/L0/001 because it does not exist or it is not a folder

To Reproduce

  const opts = {
    first: 200,
    assetType: 'All',
    groupTypes: 'ALL'
  };

CameraRoll.getPhotos(opts)
        .then((r) => {
          const { edges } = r;
          return new Promise((res, reject) => {
            edges.forEach((media) => {
            const { image: { uri } } = media.node;
            RNFetchBlob.fs.stat(uri).then((stats) => {
               Object.assign(media.node.image, { size: stats.size });
           }).catch((error) => console.log('error', error));
      });
            resolve(r);
          });
        });

Expected Behavior

Expected stats return informations

Code Example

Environment

React Native Environment Info:
System:
OS: macOS 10.14.3
CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Memory: 60.63 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 11.9.0 - /usr/local/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5314842
Xcode: /undefined - /usr/bin/xcodebuild
npmPackages:
react: 16.8.4 => 16.8.4
react-native: 0.59.1 => 0.59.1

Bug iOS Locked

Most helpful comment

@robwalkerco my bad.

Where uri is a thing given by CameraRoll:

const appleId = uri.substring(5, 41);
const ext = isPhoto ? 'JPG' : 'MOV';
return `assets-library://asset/asset.${ext}?id=${appleId}&ext=${ext}`;

I hope that helps.

All 5 comments

The new ph:// URIs that CameraRoll gives are not compatible with most libraries, if any. It will take time for them to update.

For now, you can do string manipulation to turn them into the old format of assets-library://.

@airlaser do you have an example of how the ph:// uri should look like once converted to the old format? I can't get it working seemingly whatever I try!

@robwalkerco my bad.

Where uri is a thing given by CameraRoll:

const appleId = uri.substring(5, 41);
const ext = isPhoto ? 'JPG' : 'MOV';
return `assets-library://asset/asset.${ext}?id=${appleId}&ext=${ext}`;

I hope that helps.

@robwalkerco my bad.

Where uri is a thing given by CameraRoll:

const appleId = uri.substring(5, 41);
const ext = isPhoto ? 'JPG' : 'MOV';
return `assets-library://asset/asset.${ext}?id=${appleId}&ext=${ext}`;

I hope that helps.

Thank's for help!.
I did not try this way because I change the lib for iOs (react-native-image-crop-picker) but I keep it in mind for later.

Was this page helpful?
0 / 5 - 0 ratings