插件cordova-file-transfer方法下载返回代码错误3

时间:2018-05-10 13:04:13

标签: javascript jquery cordova mobile

我想通过使用插件文件传输从我的网站下载mp3文件,但方法下载总是向我发送错误代码3.我的网站必须配置为允许第三方应用程序下载文件或它是我的代码中有错误? 我的代码是以下谢谢

function downlaodMedia(pathName){

    var file = cordova.file.DataDirectory + pathName;
    var url= encodeURI("https://www.monsite.com/medias/" + pathName);

    window.resolveLocalFileSystemURL(file, exestingfile, downloadfile);

    function exestingfile(fileEntry){

    }

    function downloadfile(){
        var fileTransfer = new FileTransfer();
        fileTransfer.download(
            url,
            file,
            function(entry){
                navigator.notification.alert('Download Successfull', null, 
                   'Download Successfull');
            },
            function(error){
                alert("download error source " + error.source);
                alert("download error target " + error.target);
                alert("download error code " + error.code);
            },
            true,
            {
                headers: {
                    "Authorization": "Basic 
                  dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
                }
            }
        );
    }
}

0 个答案:

没有答案