Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

React Native camera roll returns invalid path only for iOS

$
0
0

I have a functionality where users can import QRcode image from the phone gallery and once imported I'll decode that using jsQR. It's working fine for Android but not in iOS.

Here is my code below:

const handleImportScan = useCallback(async () => {    try {      // @ts-ignore      const uri = normalizeUri(photos[selected].node.image.uri);      const base64Image = await RNFS.readFile(uri, 'base64');      const png = PNG.sync.read(Buffer.from(base64Image, 'base64'));      const code = jsQR(        Uint8ClampedArray.from(png.data),        png.width,        png.height,      );      console.log('code:', code);      if (code) {        console.log('Found QR code', code);      }    } catch (error) {      console.log('err:', error);    }  }, [photos, selected]);

and here is my error:

err: Error: ENOENT: no such file or directory, open 'ph://CF888AC5-F690-45E8-8D05-9FFFDB8FE367/L0/001'at promiseMethodWrapper (NativeModules.js:103)at readFileGeneric (FS.common.js:160)at Object.readFile (FS.common.js:310)at _callee$ (VM6 ScanQRfromLib.bundle:150)at tryCatch (runtime.js:45)at Generator.invoke [as _invoke] (runtime.js:274)at Generator.prototype.<computed> [as next] (runtime.js:97)at tryCatch (runtime.js:45)at invoke (runtime.js:135)at runtime.js:170

I get this error from this line below:

const base64Image = await RNFS.readFile(uri, 'base64');

Appreciate if someone could help.Thanks


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>