1
RNFetchBlob
    .config({
          addAndroidDownloads: {
               useDownloadManager: true,
               //changes here
               path: RNFetchBlob.fs.dirs.SDCardApplicationDir + '/build_change_philippines.zip',
                description: 'Images Zip',
                mediaScannable: true
           }
     })
     .fetch('GET', 'http://bccms.naxa.com.np/core/project-material-photos/1')
     .then((resp) => {
          const sourcePath = resp.path();
          const targetPath = resp.path().replace('.zip', '');
          unzip(sourcePath, targetPath)
              .then((path) => {
                  console.log(`unzip completed at ${path}`);
              })
              .catch((error) => {
                  console.log(error);
              });
      });

For big file size (above 80 megabytes) above snippet of code starts the download but shows Untitled and no progress occurs and then displays Unsuccessful. The download starts again automatically and the cycle keeps on going. But the same code downloads small zip files easily.

Prakash Bokati
  • 191
  • 1
  • 11
  • whats the error returned? – Bojan Petkovic Dec 11 '18 at 19:50
  • 1
    no error is returned, the download stops and starts again automatically – Prakash Bokati Dec 12 '18 at 03:23
  • 1
    I tried downloading the file using browser, it takes a while to start the download since the server collects all the files and puts inside zip. But the browser waits for the server till the file is available and completes the download. But in case of react-native-fetch-blob the download doesn't wait till the server responds completely. The download stops and starts again. The cycle keeps on going! – Prakash Bokati Dec 13 '18 at 07:51

1 Answers1

1

You need to set the connection timeout then.

When you make a request to the server: the server takes XXX seconds before responding that it even got the request (while it creates the zip...). If this is not configured, the client will assume the server never got the response and shut down by itself.

try adding:

"timeout": 60000

to the fetch request.

Bojan Petkovic
  • 2,406
  • 15
  • 26
  • thanks for your suggestion. The fetch does not support timeout feature. And the react-native-fetch-blob's config object does not seem to accept timeout property. – Prakash Bokati Dec 16 '18 at 07:44
  • 1
    How do I made the download manager wait till the server serves the file? – Prakash Bokati Dec 21 '18 at 08:36
  • something like this: https://stackoverflow.com/questions/42147733/doing-a-timeout-error-with-fetch-react-native – Bojan Petkovic Jan 03 '19 at 19:20
  • 2
    Once the download manager is fired, the process is already under the control of the operating system. There is no way one can utilize a timeout feature. Actually, we tackled the problem by keeping zip ready at all times. Such a scenario is meant to be controlled at the server side. – Prakash Bokati Jan 27 '19 at 13:07