joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.81k stars 772 forks source link

Cant copy files #707

Closed armata99 closed 3 years ago

armata99 commented 3 years ago

Hi im trying to copy a file into cache directory using cp but i get this error I dont know why

[Error: Attempt to invoke virtual method 'boolean java.lang.String.startsWith(java.lang.String)' on a null object reference]

here is my code:

RNFetchBlob.fs
          .cp('content://com.android.providers.downloads.documents/document/msf%3A2008', RNFetchBlob.fs.dirs.CacheDir+'/myfile.pdf')
          .then((result) => {
            console.log(result);
            let uploadedFile = pickedFile;
            uploadedFile.storageUri = pickedFile.uri;
            this.setState({
              isLoading: false,
              pickedFile: '',
              previousFile: uploadedFile,
            });
          })
          .catch((err) => console.log(err));

here is my info:

react: 16.13.1 => 16.13.1 react-native: 0.63.2 => 0.63.2

test device: Samsung galaxy a51 with android 10

burak4ydin commented 3 years ago

same for me, any solution?

armata99 commented 3 years ago

Hi. Sadly this repo does not seem to be maintained anymore. You can switch to react-native-fs. see the docs here