Cordova 视频文件上传 Android 10 目标级别 29 不起作用

问题描述

我在使用目标级别 29 上传错误代码 = 1 的视频文件时遇到问题,文件未传输但该文件视频工作正常并保存在本地设备中。

我认为是上传时的问题或路径不正确。 我已经用 toURL() 更改了 fullPath 但没有影响,包括在清单中添加 android.permission.ACTION_MANAGE_STORAGE 但问题仍然存在。

以前在级别升级之前工作正常。

这是代码

function take_video()
{
    // capture callback
    var captureSuccess = function(mediaFiles) {
        var i,path,len;
        for (i = 0,len = mediaFiles.length; i < len; i += 1) {
            path = mediaFiles[i].fullPath;
            console.log(path);

            $(".vv").html('<video width="300" height="400" controls>\
                <source src="'+path+'" type="video/mp4">\
                <source src="'+path+'" type="video/ogg">\
                Your browser does not support the video tag.</video>');
            // do something interesting with the file


            var fileURL = path;
            
            var win = function (r) {
                console.log("Code = " + r.responseCode);
                console.log("Response = " + r.response);
                console.log("Sent = " + r.bytesSent);
            }

            var fail = function (error) {
                alert("An error has occurred: Code = " + error.code);
                console.log("upload error source " + error.source);
                console.log("upload error target " + error.target);
            }

            var options = new FileUploadOptions();
            options.fileKey = "file";
            options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
            options.mimeType = "video/mp4";

            var params = {};
            params.value1 = "test";
            params.value2 = "param";

            options.params = params;

            options.chunkedMode = false;
            var ft = new FileTransfer();

            video_link = fileURL.substr(fileURL.lastIndexOf('/') + 1);

            ft.upload(fileURL,encodeURI("http://xxx/api/video.PHP?method=upload_video_file&video_link="+video_link+"),win,fail,options);            

            
            $(".video_link").val(video_link);


        }
    };

    // capture error callback
    var captureError = function(error) {
        navigator.notification.alert('Error code: ' + error.code,null,'Capture Error');
        // navigator.notification.alert('Error code: ' + error.code,'Capture Error');
    };

    // start video capture
    navigator.device.capture.captureVideo(captureSuccess,captureError,{limit:1,duration: 15,quality: 0});
}





$(document).ready(function(){
    $('.foto_desc').submit(function() {
        $.ajax({
            type: 'POST',url: 'https://xxxxx/api/video.PHP?method=update_video&config='+set_config,data: $(this).serialize(),success: function(data) {
                window.location = 'index.html';
            }
        })
        return false;
    }); 
});

这里是 API

function upload_video_file()
{
    $nd = date("Ymdhis");
    $new_image_name = $_GET['video_link'];
    $direktori = 'video_aktifitas/'.$new_image_name;
    echo $source = $_FILES['file']['tmp_name']; 
    
    
    if(move_uploaded_file($source,$direktori))
    {
        //xxxx
    }
}


function update_video() {
    //xxx
}

我的插件列表:

(node:12168) ExperimentalWarning: The fs.promises API is experimental
cordova-android-support-gradle-release 3.0.1 "cordova-android-support-gradle-release"
cordova-plugin-background-mode 0.7.2 "BackgroundMode"
cordova-plugin-camera 4.0.3 "Camera"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-file-transfer 1.7.1 "File Transfer"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-media-capture 3.0.3 "Capture"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova.plugins.diagnostic 4.0.12 "Diagnostic"

谁能帮帮我?提前致谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)