I am using Ionic 3 to build my Mobile Application and I have to download a file on request. As well I need to get the response header information of the downloaded file. I am using File Transer plugin (https://ionicframework.com/docs/native/file-transfer/) to download the file.
Below is what I am doing.
downloadAndOpen(downloadURL, attachmentName) {
let options: FileUploadOptions = {
headers: {'Authentication-Info': localStorage.getItem("SessionID")}
}
var savePath = this.file.dataDirectory + attachmentName;
this.fileTransfer.download(downloadURL, savePath, false, options).then((entry) => {
// Need to get the Header information.
});
}
On initiating the download with the required parameters, it got success and the response I got is like
{
filesystem: FileSystem {name: "library-nosync", root: DirectoryEntry, __format__: function, toJSON: function}
fullPath: "/Java Collections Framework.pdf"
isDirectory: false
isFile: true
name: "Java Collections Framework.pdf"
nativeURL: "file:///var/mobile/Containers/Data/Application/5381B42F-AAD5-4A43-BE87-6E488BEA3A93/Library/NoCloud/Java%20Collections%20Framework.pdf"
}
The server team is sending few sensitive informations in the Response header which will be used on downloading the document. I didn’t find proper information in Ionic Native File Transfer plugin to get the the Response Header information.