Reputation: 61
Let's say I have a JSON object containing users' profile including firstname, lastname,..., and profileUrl from a web API. I've already saved the text data using Sqlite, and now I want to save those images in native storage and put the file path into the sqlite database replacing the profileUrl.
Upvotes: 1
Views: 455
Reputation: 6544
You can use cordova-plugin-file-transfer
for that. There is even an Ionic Native wrapper available: https://ionicframework.com/docs/native/transfer/
Example:
download() {
const url = 'http://www.example.com/file.pdf';
fileTransfer.download(url, this.file.dataDirectory + 'file.pdf').then((entry) => {
console.log('download complete: ' + entry.toURL());
}, (error) => {
// handle error
});
}
Upvotes: 2