Gab*_*ira 5 android typescript ionic-framework angular capacitor
我正在开发一个函数来捕获和读取 KML 文件,以及另一个函数来解压缩并保存 KMZ 文件(基本上是 zip)内的这些文件。
在第一次尝试中,我无法访问它,因为错误告诉我我没有正确的权限,但根据电容器文档和添加后android:requestLegacyExternalStorage="true",AndroidManifest.xml我可以获得访问设备文件的正确权限。之后,我必须使用FilePathFilePath.resolveNativePath(path);中的函数来过滤 URI 。原始路径由 生成,URI 是文件的根路径。fileChooser.open().then(uri=>{})
在使用 API 29/v10 和 API 30/v11 的 Android 模拟器以及使用 API 29/v10 的物理 Android 设备进行一些测试后,我能够使这些功能正常工作,但在物理设备中有一个特定的文件夹 Documents,无法访问并生成错误:
“错误错误:未捕获(承诺):对象:{“code”:0,“message”:“无法解析文件系统路径。”}”。
selectFile(): Promise<void>{
if (this.platform.is('cordova')) {
return this.fileChooser.open().then(uri => {
return this.filePath.resolveNativePath(uri).then(uri => {
let filename = uri.split('/').pop();
this.layerName = filename;
this.fileURI = uri;
});
});
}
}
Run Code Online (Sandbox Code Playgroud)
版本前的 URI:content://com.android.externalstorage.documents/document/home%3Apoligono.kml.
版本后的 URI:运行函数 FilePath.resolveNativePath(uri); 后发生错误。这种情况仅发生在物理设备中的这个特定文件夹中。
| 归档时间: |
|
| 查看次数: |
1745 次 |
| 最近记录: |