You can Achieve this in the following steps :
Step 1: A download function to download from URL
downloadFile(path: string, body: Object = {}): Observable<any> {
let headers = {} // add authentication headers and other headers as per your requirement
return this.http.post/get(
`${path}`, body, { headers: headers, withCredentials: true }
)
.catch((err) =>console.log(err))
.map((res:Response) => res)
.finally( () => { });
}
Step 2: Use the download function to convert it into an appropriate Blob.
this.downloadFile(`url`, postData).subscribe(
res => {
let options = { type: ‘filetype’ };
let filename = ‘filename.type’;
Util.createAndDownloadBlobFile(res._body, options, filename);
},
err => {
// show the error
}
);
Step 3: Save the Blob Data on Device using following plugin https://github.com/apache/cordova-plugin-file