When I am trying to get all files from sccard directory, it throws an exception.
I am testing on android, samsung TAB A. Has anyone the problem like this.
thanks in advance :)
code snipet:
RNFetchBlob.fs.ls(PATH_TO_DIRECTORY).then(async files => {
alert(files.length);
}).catch(error => {
alert(error);
});
Does this only happen on Android? It might be that your application doesn't have the external read/write permissions either in the manifest, or if your Samsung TAB is running Android 6.0+, it isn't asking for storage permissions at runtime.
If you can post the exception you are seeing, it might help to narrow down the problem.
@tombailey thank you for your response. I defined every persmissions, in manifest file. Interesting thing is that, it works with old "react-native-fetch-blob" but not works with "rn-fetch-blob"
import RNFetchBlob from 'rn-fetch-blob'; // Not works with this library
import RNFetchBlobOld from 'react-native-fetch-blob'; // Works correctly
RNFetchBlobOld.fs.ls(PATH).then(files => {
// Works
});
RNFetchBlob.fs.ls(PATH).then(files => {
// Not works
});
Here is the exception:
RNFetchBlob.ls got 1 arguments, expected 2
invoke
JavaMethodWrapper.java:353
invoke
JavaModuleWrapper.java:160
run
NativeRunnable.java
handleCallback
Handler.java:751
dispatchMessage
Handler.java:95
dispatchMessage
MessageQueueThreadHandler.java:29
loop
Looper.java:154
run
MessageQueueThreadImpl.java:192
run
Thread.java:761
Android OS 7.0, api level 24.
Can you tell us the versions of react-native as well as the versions of react native fetch blob that you are using? (both the old version and new version)
Looking back at the original react-native-fetch-blob repo it seems to require a callback parameter, so I'm not quite sure how using the old fetch blob is not failing when you aren't passing in a callback
I am using following versions:
{
"react-native": "0.55.3",
"react-native-fetch-blob": "^0.10.8",
"rn-fetch-blob": "^0.10.11"
}
facing same issue.
same issue, is it a bug of new version at 0.10.13 ? because I find it is correct of old version at 0.10.8
I believe we need to annote the native static function with "@reactmethod". I can't do this right now but will try later.
This:
static void ls(String path, Promise promise) {
//...
}
Should become this:
@ReactMethod
static void ls(String path, Promise promise) {
//...
}
Any update on this issue, running into something similiar.
RNFetchBlob.mkdir was called with 1 arguments but expects 2 arguments.
https://www.dropbox.com/s/p4bwx573uyp0p11/Screenshot%202018-10-02%2022.38.30.png?dl=0
Coming here from this plugin which uses rn-fetch-blob https://github.com/fungilation/react-native-cached-image.git
@xhw1993 this appears to be fixed as of 0.10.13
Any update on this issue, running into something similiar.
RNFetchBlob.mkdir was called with 1 arguments but expects 2 arguments.
https://www.dropbox.com/s/p4bwx573uyp0p11/Screenshot%202018-10-02%2022.38.30.png?dl=0
Coming here from this plugin which uses rn-fetch-blob https://github.com/fungilation/react-native-cached-image.git
@rollsroyc3 same issue here, did you ever find a solution?
@CurrieBen can you ask them to update their fetchblob version to 0.10.13? I tested this back in October and it seemed to be okay on 0.10.13
This is still an issue. Native library expects a callback (which is largely unused), which this library does not provide, thus causing this error. You can patch this yourself in node_modules by adding an empty callback function.
If anyone is using redux-persist-filesystem-storage, they need to pin their version to 1.2.0 (ie. "redux-persist-filesystem-storage": "1.2.0" (removing the ^ in front of the version n umber), otherwise they'll get this fork instead, which is actually broken.
@scarlac Tried adding the empty callback as a temporary solution, works for me, thanks!
@CurrieBen can you ask them to update their fetchblob version to 0.10.13? I tested this back in October and it seemed to be okay on 0.10.13
npm install [email protected] --save
npm ERR! code ETARGET
npm ERR! notarget No matching version found for [email protected]
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/hiren/.npm/_logs/2019-03-07T12_09_17_975Z-debug.log
@scarlac Tried adding the empty callback as a temporary solution, works for me, thanks!
@afomer Good day to you.
Can you give more detail on how to adding the empty callback? I stuck this error and so tired now, hope you can share
this is still a problem. @scarlac @afomer could you guys please provide more details of your temporary solution? thanks.
@jpodpro For my "fix", please edit your package.json file. Find where it says:
"redux-persist-filesystem-storage": "xxx",
where xxx is some version number. Version number may include a special character like ^ or ~.
Remove the special character and type 1.2.0 so it reads:
"redux-persist-filesystem-storage": "1.2.0",
Then, if you're using NPM, run this in your project folder: rm -rf node_modules && npm install
Replace npm with yarn if you're using yarn (like I am)
@scarlac i'm not using this library. i was asking for your custom callback function patch. i've tried adding an empty function everywhere that makes sense but i still get errors.
I personally do not recommend patching your node_modules package, as the change will disappear next time you reinstall the module. It's not a solution, just a way to debug the issue temporarily.
@scarlac i'm well aware of the implications. however given that this has been reported for nearly a year i would happily rather fix this myself for now while we're stuck indefinitely waiting.
after completely starting from scratch this error went away - i'm assuming it comes from migrating from react-native-fetch-blob, although i had unlinked, removed node_modules and re-installed which didn't fix it. i had to create a new react native project and import my existing code.
@scarlac Tried adding the empty callback as a temporary solution, works for me, thanks!
@afomer Good day to you.
Can you give more detail on how to adding the empty callback? I stuck this error and so tired now, hope you can share
Very for the late reply. I added () => {} as an argument to RNFetchBlob.emitExpiredEvent in the file index.js. I hope that's helpful!
The exact snippet edit:
// when app resumes, check if there's any expired network task and trigger
// their .expire event
if(Platform.OS === 'ios') {
AppState.addEventListener('change', (e) => {
if(e === 'active')
RNFetchBlob.emitExpiredEvent(()=>{})
})
}
Most helpful comment
This is still an issue. Native library expects a callback (which is largely unused), which this library does not provide, thus causing this error. You can patch this yourself in node_modules by adding an empty callback function.
If anyone is using redux-persist-filesystem-storage, they need to pin their version to
1.2.0(ie."redux-persist-filesystem-storage": "1.2.0"(removing the^in front of the version n umber), otherwise they'll get this fork instead, which is actually broken.