假设我有一个包含用户配置文件的JSON对象,包括Web API的firstName,lastName,...和profileRl。我已经使用sqlite保存了文本数据,现在我想将这些图像保存在本机存储中,并将文件路径放入sqlite数据库中,以替换配置文件。
您可以使用cordova-plugin-file-transfer
。甚至还有一个离子本机包装器:https://ionicframework.com/docs/native/transfer/
示例:
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
});
}