Skip to content

Instantly share code, notes, and snippets.

@redlotus
Created December 16, 2016 08:44
Show Gist options
  • Save redlotus/52def6dc9c4c89a9c3a47c42a505063d to your computer and use it in GitHub Desktop.
Save redlotus/52def6dc9c4c89a9c3a47c42a505063d to your computer and use it in GitHub Desktop.
downloadFileUsingFileTransfer.ts
downloadFile(id: string, name: string) {
this.platform.ready().then(() => {
const fileTransfer = new Transfer();
let url = constants.API_ENDPOINT + '/web/binary/saveas?model=ir.attachment&field=datas&filename_field=name&id=' + id;
console.log(url);
// let downloadBrowser = new InAppBrowser(url, '_system');
fileTransfer.download(url, cordova.file.externaldataDirectory + name, true)
.then((entry) => {
console.log('download complete: ' + entry.toURL());
}, (error) => {
console.log(error);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment