Created
December 16, 2016 08:44
-
-
Save redlotus/52def6dc9c4c89a9c3a47c42a505063d to your computer and use it in GitHub Desktop.
downloadFileUsingFileTransfer.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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