【发布时间】:2021-09-21 14:46:19
【问题描述】:
我使用了 nativescript-imagepicker (related website),并按照文档和示例代码中的方式实现了所有内容。
我还在 AndroidManifest.xml 中设置了权限代码,该代码针对 API 29 及更高版本进行了修复,但不幸的是,在从设备图库中选择照片后出现此错误:
找不到资产“content://com.android.providers.downloads.documents/document/..._photos.jpg”。
代码:
let context = imagepicker.create({
mode: "single"
});
context.authorize()
.then(() => {
return context.present();
}).then(selection => {
const imageAsset = selection.length > 0 ? selection[0] : null;
imageAsset.options.height = 1024;
imageAsset.options.width = 1024;
imageAsset.options.keepAspectRatio = true;
ImageSource.fromAsset(imageAsset).then((imageSource: ImageSource) => {
this.defaultImage = "";
this.changedImage = imageSource;
this.uploadImage(imageSource);
}, (err) => {
console.log(err);
})
})
.catch(function (e) {
console.log(e);
});
AndroidManifest.xml:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application android:requestLegacyExternalStorage="true" ... >
PS:有人写道,将compileSdkVersion = 29 添加到 app.gradle 应该可以解决它,但那不起作用!
有人可以帮忙吗?
【问题讨论】:
标签: angular nativescript