Ionic [$cordovaFile.writeFile] memory limitations and how to get around them


#1

I am using $cordovaFile.writeFile to save a zip file to iPad. The zip file contents are send by Node server and passed to the below function in data parameter.

var saveZipToiPad = function (data, fileName) {
      console.log('Saving file ' + fileName + ' to iPad');
      return $cordovaFile.writeFile($rootScope.dataDirectory, fileName, data, true)
        .then(function (result) {
          console.log('Data saved to device');
          return true;
        })
        .catch(function(err) {
          console.log(JSON.stringify(err));
        });
    };

This code works absolutely fine for small files (lets say a zip file with 5-6MB size). However, when it runs for larger files like 50MB size, the app crashes (app closes). In the xcode logs, it gives the below error

2016-10-09 21:21:09.454 MyApp[3168:700308] Received memory warning.
Message from debugger: Terminated due to memory issue

Is there some kind of memory limit beyond which writeFile would not be able to save files? I could not find anything like that in the docs.

How can I make my app work for large sized files, 50-60MB size?