react-native-blob-util icon indicating copy to clipboard operation
react-native-blob-util copied to clipboard

Get two files when using Download Manager in Android 11 and one of them comes empty

Open GabrielGomesBarbosa opened this issue 6 months ago • 2 comments

Expected Behavior

Download just one file when using Download Manager in Android 11


My Code

   const dirs = RNFetchBlob.fs.dirs;

    let addAndroidDownloads: AddAndroidDownloads = {
      title: fileName,
      description: 'Download success',
      mediaScannable: true,
      notification: true,
      useDownloadManager: true,
      mime: metadata.mimeType,
      path: `${RNFS.DownloadDirectoryPath}/${fileName}`,
    };

    const res = await RNFetchBlob.config({
      fileCache: true,
      path: `${dirs.CacheDir}/${fileName}`,
      addAndroidDownloads,
    }).fetch('GET', url);

Current Behavior

This create 2 files, one is correct, but the other comes with 0 bytes

The notification is working fine:

image

But in download folder:

image


Env

react-native: "0.72.4" react-native-blob-util: "0.17.1" Android API Level: API 30


Important Informations

  • I have already tested with versions "0.19.4" and "0.19.6" from react-native-blob-util
  • Android 6 and 13 are working fine

GabrielGomesBarbosa avatar Dec 14 '23 14:12 GabrielGomesBarbosa

Did there already exist a file with the same name? Some Android versions were struggling if the filename was already used. That's the reason for me asking

RonRadtke avatar Apr 07 '24 12:04 RonRadtke

This error always happens if there exists a file with the same name. The second file will be either empty or produce an error. Any ideas for fixing this?

UIT19521334 avatar Apr 22 '24 09:04 UIT19521334