Is that a way to connect to a server via https and download a file. I'm using File Transfer but I can't authenticate. (Using wget I can access)
This is what a try :
let url = "https://0.0.0.0:0000/maps/"+element['file'];
this.fileTransfer = this.transfer.create();
this.fileTransfer.download(url, res.nativeURL+""+element['file']).then((entry) => {
console.log('download complete: ' + entry.toURL());
}, (error) => {
console.log(error);
});
The url is not my real url, just to show you. Any idea? I have to put username and password. Like for api in header append.
According to the Ionic 3 docs you can use headers with the download function.
https://ionicframework.com/docs/native/file-transfer/#download
download(source, target, trustAllHosts, Optional)
Param | Type | Details
Optional
|object
| parameters, currently only supports headers (such as Authorization (Basic Authentication), etc).
Example:
let options = {
headers: {
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
}
}
this.fileTransfer.download(url, res.nativeURL + "" + element['file'], false, options).then((entry) => {
console.log('download complete: ' + entry.toURL());
}, (error) => {
console.log(error);
});