Unable to save file to device with Ionic native http

We have a mobile app developed using Angular 7 & Ionic 4. A while back we conducted a penetration test and, in order to be compliant, we changed the way files are transferred in the app. Instead of getting the file url directly through API, we receive an url of which the content type is application/octet-stream, and we use the following method to download the file and save it in device storage:

downloadFileTransfer(url, fileName) {
  const directoryPath = this.device.platform === 'Android' ? this.file.dataDirectory : this.file.documentsDirectory;
  const filePath = directoryPath + fileName;
  alert("url:" + url);
  alert("filePath:" + filePath);
  this.nativeHTTP.downloadFile(encodeURI(url), {}, {}, filePath).then(response => {
    this.appService.toastTipSuccess('success: ' + response, false);
    alert('response: ' + JSON.stringify(response));
  }).catch(err => {
    this.appService.toastTip('failure: ' + err, false);
  });
}

With this code on a real Android device, I can see the url and filePath being alerted just fine, and the response alert after downloadFile callback can be triggered just fine with response object containing the actual path where this file is supposed to be saved at. However, after checking the device storage, nothing is actually saved in the device, despite the response callback is triggered successfully.

On a side note, this is the latest attempt after many other alternatives failed: saveAs, createObjectURL, fileTransfer.download. Despite many of those approaches work in web browser, none of which worked in standalone app on real mobile devices.

Any insights or assistance would be greatly appreciated, as this issue has bothered our team for several weeks already.

First, it would be great if you actually linked to the plugin you are using. Also, Ionic Native has been replaced as of 2021 - A New Chapter for @ionic-native - Ionic Blog.

I think I did find the plugin you are using and it would be best to reach out on that repo directly (and search the issues there) - GitHub - silkimen/cordova-plugin-advanced-http: Cordova / Phonegap plugin for communicating with HTTP servers. Allows for SSL pinning!.

As a side note, Capacitor has a first party filesystem plugin now - Filesystem Capacitor Plugin API | Capacitor Documentation.