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

Android 9 Error: mkdir failed to create some or all directories in '/storage/emulated/0/ #690

Closed Joshmatjjen closed 3 years ago

Joshmatjjen commented 3 years ago

Any time i type the Error below, I get an error : Error: mkdir failed to create some or all directories in '/storage/emulated/0/

RNFetchBlob.fs.mkdir( RNFetchBlob.fs.dirs.SDCardDir + '/myDownloader', );

"rn-fetch-blob": "^0.12.0", "react-native": "0.62.2",

PLEASE HELP

PedroTrogo commented 3 years ago

are permissions for external storage already granted?

Joshmatjjen commented 3 years ago

Yes... It work Well for Android 7.0

GunturThunder commented 3 years ago

add permissions like this, if permission is true then mkdir like:

const granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE, { title: "message...", message: "message...", buttonNeutral: "message..", buttonNegative: "No", buttonPositive: "Yes" } ); if (granted === PermissionsAndroid.RESULTS.GRANTED) { RNFetchBlob.fs.exists(RNFetchBlob.fs.dirs.SDCardDir + '/myDownloader/') .then((exist) => { if (!exist) { RNFetchBlob.fs.mkdir( RNFetchBlob.fs.dirs.SDCardDir + '/myDownloader/') .then(() => { console.log('file add') }) .catch((err) => { console.log('error',err) }) } }) .catch((error) => console.log('error', error)) }

paulonteri commented 3 years ago

Same issue

PedroTrogo commented 3 years ago

try to add requestLegacyExternalStorage in AndroidManifest

<manifest ... >
<!-- This attribute is "false" by default on apps targeting
     Android 10 or higher. -->
  <application android:requestLegacyExternalStorage="true" ... >
    ...
  </application>
</manifest>
MAzeem6778 commented 3 years ago

Do you find any work around for this?

Malik-Usman17 commented 2 years ago

Still facing this issue can't create the directory on my device.