Error on iOS with RNFS.read function
When attempting to read a file with RNFS.read like this:
const chunk = await RNFS.read(uri, CHUNK_SIZE, position, 'base64')
I get this error: [Error: RNFSManager.read(): Error while converting JavaScript argument 1 to Objective C type NSInteger. Objective C type NSInteger is unsupported.]
"react-native-fs": "^2.20.0", "react-native": "0.76.5",
This issue is with the length and position parameters in RNFSManager.m read method:
Should be: RCT_EXPORT_METHOD(read:(NSString *)filepath length: (NSInteger)length position: (NSInteger)position resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
instead of: RCT_EXPORT_METHOD(read:(NSString *)filepath length: (NSInteger *)length position: (NSInteger *)position resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
Here is a patch file in case others run into this issue:
I am facing the same issue The patch worked
Same issue for me on iOS:
"react-native": "^0.78.2",
"react-native-fs": "2.20.0",
The patch worked
For newer versions of React Native, use this repository: https://github.com/birdofpreyru/react-native-fs