react-native-fs icon indicating copy to clipboard operation
react-native-fs copied to clipboard

Error on iOS with RNFS.read function

Open keithdmoore opened this issue 10 months ago • 4 comments

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",

keithdmoore avatar Feb 21 '25 21:02 keithdmoore

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:

react-native-fs+2.20.0.patch

keithdmoore avatar Feb 21 '25 21:02 keithdmoore

I am facing the same issue The patch worked

AtilMohAmine avatar Mar 16 '25 21:03 AtilMohAmine

Same issue for me on iOS:

"react-native": "^0.78.2",
"react-native-fs": "2.20.0",

The patch worked

dgreasi avatar Apr 28 '25 13:04 dgreasi

For newer versions of React Native, use this repository: https://github.com/birdofpreyru/react-native-fs

felixrolando avatar Jul 31 '25 16:07 felixrolando