File Transfer Download crashes ! Why?

Where is problem??
I am calling it within app.component.ts. Also tried home.ts. Everytime crash app. There are 1200 pages and return json for every page. I have tried android:largeHeap=“true”

 getAllData() {
       let fileTransfer: FileTransferObject = this.transfer.create();
        for (var i = 1; i < 1200; i++) {
             let url = encodeURI('Here is API URL' + i + '/G');
                fileTransfer.download(url, this.file.dataDirectory + 'G' + i + '.json').then((entry) => {
               // Nothing comes here....
                }, (error) => {
                    // handle error
                });
            }
    }

i think you can use with onProgress function

Still no luck. What to do?

Need to change your code idea too many files cannot save on device and ram;
if i was do, one by one on the pages

1 Like

@Amara, hello, I see you suggest onProgress function, I just want to ask if you can make “onPregress” function work with IOS ? for me onProgress work only Android

1 Like


Yes, I use this plugin, but I can get loaded data size from “onProgress” only android

1 Like

Can you share some code sample?

i think it`s a same

How it will be helpful to download json file from api?

You can download anything

1 Like

but, if you have Json file, I think you don’t need to download it, just use it directly or store in local storage

1 Like

This design seems nuts to me. Instead of 1200 network requests on every app launch, why not package everything into a single JSON object and either save it to Ionic Storage or embed it into the app binary?

3 Likes

oh i forgot
it`s my old code; i had not use onprogress it is simple code

###ts
...
const fileTransfer: FileTransferObject = this.transfer.create();
this.isbusy = id;
// Download a file:
fileTransfer.download(url, cordova.file.dataDirectory + video, true).then((entry) => {
    this.isbusy = 0;
}, (error) => {
  // handle error filetransfer
  console.log('video tatalt aldaa!');
});
...

###html

... 
<ion-icon *ngIf="isbusy!=content.id" name="download"></ion-icon> 
<ion-spinner *ngIf="isbusy==content.id" name="bubbles"></ion-spinner>
...