微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。