Skip to content

Error on iOS with RNFS.read function #1246

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

Open
keithdmoore opened this issue Feb 21, 2025 · 3 comments · May be fixed by #1247
Open

Error on iOS with RNFS.read function #1246

keithdmoore opened this issue Feb 21, 2025 · 3 comments · May be fixed by #1247

Comments

@keithdmoore
Copy link

keithdmoore commented Feb 21, 2025

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
Copy link
Author

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

@AtilMohAmine
Copy link

AtilMohAmine commented Mar 16, 2025

I am facing the same issue
The patch worked

@dgreasi
Copy link

dgreasi commented Apr 28, 2025

Same issue for me on iOS:

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

The patch worked

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

Successfully merging a pull request may close this issue.

3 participants