Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Ionic-上传视频时出现EACCES(权限被拒绝)错误_Android_Cordova_Ionic Framework_Cordova Plugins - Fatal编程技术网

Android Ionic-上传视频时出现EACCES(权限被拒绝)错误

Android Ionic-上传视频时出现EACCES(权限被拒绝)错误,android,cordova,ionic-framework,cordova-plugins,Android,Cordova,Ionic Framework,Cordova Plugins,我在尝试使用和将视频文件上载到服务器时遇到一些困难。从gallery上传图像时,代码就像一个魔咒,但无论我做什么,从gallery上传视频时,我总是收到EACCES(权限被拒绝): file url -> file:///storage/emulated/0/DCIM/Camera/VID_20200908_114957.mp4 post-post-module-es2015.js:240 {status: -1, error: "There was an error with

我在尝试使用和将视频文件上载到服务器时遇到一些困难。从gallery上传图像时,代码就像一个魔咒,但无论我做什么,从gallery上传视频时,我总是收到
EACCES(权限被拒绝)

file url ->  file:///storage/emulated/0/DCIM/Camera/VID_20200908_114957.mp4
post-post-module-es2015.js:240 {status: -1, error: "There was an error with the request: /storage/emulated/0/DCIM/Camera/VID_20200908_114957.mp4: open failed: EACCES (Permission denied)"
仅查看错误消息,我们可以得出结论,这是一个权限问题,因此我尝试使用并请求读取外部存储权限。未成功,应用程序具有权限,但错误保持不变

这是用于上传的部分代码

private chooseContentUsingCameraPlugin(SOURCE: number) {
    const options: CameraOptions = {
        destinationType: this.camera.DestinationType.FILE_URI,
        mediaType: this.camera.MediaType.ALLMEDIA,
        sourceType: SOURCE
    };
    this.camera.getPicture(options).then((contentUrl: string) => {
        if (contentUrl.indexOf('://') === -1)
            contentUrl = 'file://' + contentUrl;
        const queryIndex = contentUrl.lastIndexOf('?');
        if (queryIndex !== -1)
            contentUrl = contentUrl.substring(0, queryIndex);
        console.log('file url -> ', contentUrl);
        this.startUpload(contentUrl);
    }, (err) => this.onUploadError(err));
}

private startUpload(fileUrl){
    ...
    this.nativeHttp.uploadFile(req.url, null, headers, fileUrl, fileName).then(res => {
        let data = res.data;
        if (res.data && (req.responseType === undefined || req.responseType === 'json'))
            data = JSON.parse(res.data);
        console.log(data)
    }).catch(error => {
        console.log(error)
    });
}

是否有人可以解释导致此问题的原因?

您试图上载的文件可能不在您的权限范围内。这是政府所说的:

这是一个软限制权限,在记录中的安装程序将该权限列入白名单之前,应用程序无法以其完整形式持有该权限。具体而言,如果权限被列入白名单,持有者应用程序可以访问外部存储以及视听媒体收藏,而如果权限未列入白名单,持有者应用程序只能访问视听媒体收藏。此外,权限是不可变的限制,这意味着白名单状态只能在安装时指定,并且在安装应用程序之前无法更改。有关更多详细信息,请参阅