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

[Error: Unexpected FileStorage response file: null] on android 14

Open YASH6004 opened this issue 9 months ago • 2 comments

Hi,

- Steps to replicate the issue

  1. Grant permission to the app
  2. download the data with the given code [it will download the zip file from the URL using cookie-based authentication ]
  3. now delete the created folder from android > download > ${filename} [ delete the whole folder ]
  4. now try to download again it will throw this error but this will create the folder ${filename}
  • Screenshot 2024-05-24 at 1 52 25 PM
  • RN version "react": "18.1.0", "react-native": "0.70.6",

  • android version 14
    Device Samsung s23 ultra

*here is my code sinnpet ''' export const exportClientData = async (type: 'all' | 'single', client_id?: string) => { let filepath = ''; let url = '';

if (type === 'all') { url = https://...; } else if (type === 'single') { url = https:///.......; }

// Get the app's cache directory const { fs } = ReactNativeBlobUtil; const cacheDir = Platform.OS === 'ios' ? fs.dirs.DocumentDir : fs.dirs.LegacyDownloadDir;

// Define the filename const filename = 'filename';

// Construct the full filepath if (type === 'all') { filepath = ${cacheDir}/${filename}/ClientData.zip; } else if (type === 'single') { filepath = ${cacheDir}/${filename}/${client_id}.zip; }

try { // // Ensure the directory exists // const dirPath = ${cacheDir}/${filename}; // const isDir = await fs.isDir(dirPath); // Check if the directory exists

  // if (!isDir) {
  //     await fs.mkdir(dirPath); // Create the directory if it does not exist
  // }

  // Download the file and save it to the cache directory
  const configOptions:any = Platform.select({
      ios: {
          fileCache: true,
          path: filepath,
          appendExt: 'zip',
      },
      android: {
          fileCache: true,
          path: filepath,
          appendExt: 'zip',
      },
  });

  const response = await ReactNativeBlobUtil.config(configOptions).fetch('GET', url, {
      "Accept": "*/*",
      "Accept-Encoding": "*/*",
  });
  console.log('response==>>', JSON.stringify(response, undefined, 4));
  return response;

} catch (error) { console.error('error in downloading==>', error); return error; } }; '''

YASH6004 avatar May 24 '24 08:05 YASH6004