ios - ionic-native/file + ionic-native/http 下载不工作
问题描述
使用此答案中的代码https://stackoverflow.com/a/63585081/7751910并且无法使其正常工作。没有物理 ios 设备,所以使用 Xcode 模拟器。这是我使用 console.log() 的代码:
public downloadFileAndStore(fileUrl: string): void {
let filePath: string;
if (this.platform.is('ios')) {
filePath = this.file.documentsDirectory + this.getFileName(fileUrl);
} else { // for iOS use this.file.documentsDirectory
filePath = this.file.dataDirectory + this.getFileName(fileUrl);
}
this.nativeHTTP.downloadFile(fileUrl, {}, {}, filePath).then((response: any) => {
// prints 200
console.log('download success', response);
for (const key in response) {
if (Object.prototype.hasOwnProperty.call(response, key)) {
const element = response[key];
console.log(key);
console.log(element);
}
}
}).catch((err: any) => {
// prints 403
console.log('download error', err.status);
// prints Permission denied
console.log('download error', err.error);
});
}
但是仍然没有下载任何内容。
更新:在真实设备上也不起作用
解决方案
推荐阅读
- ios - 错误:未能获得进程的任务
- regex - 修复街道地址正则表达式验证
- php - 这个问题:警告:非法偏移类型
- android - 即使在使用自定义 rom MiUi pro 10 刷新后也会加载旧启动徽标。 TWRP
- android - 如何处理视图模型内服务类中触发的事件?架构组件、Kotlin、Firebase)
- javascript - 需求和内存:在全局或函数范围内使用
- node.js - 用于 Node Angular 应用程序部署的 Google Codelab 执行失败
- c - Redis 的静态函数根本没用
- reactjs - (Git) 如何推送未做任何更改的文件?
- javascript - 如何使用 jquery 从 api 响应中检查要检查的单选和复选框的正确值