【问题标题】:Cordova file transfer plugin using https not working for windows使用 https 的 Cordova 文件传输插件不适用于 Windows
【发布时间】:2016-05-31 11:07:25
【问题描述】:

我目前正在使用cordova 文件传输插件下载文件并将其保存在本地。我正在使用 https 并且服务器证书已安装在设备中。

它适用于IOS和android,但它不适用于Windows。

我能够调试到插件的代码,它会在这部分出错并显示“发生安全问题”的错误消息,现在将返回到应用程序并显示 FTErr.CONNECTION_ERR:

var downloadOperation = download.startAsync();
// update internal TransferOperation object with newly created promise
fileTransferOps[downloadId].promise = downloadOperation;
downloadOperation.then(function () {...}, function(error) 
{
    if (error.message === 'Canceled') {
       resolve(new FTErr(FTErr.ABORT_ERR, source, target, null, null, error));
    } else if (error && error.number === HTTP_E_STATUS_NOT_MODIFIED) {
       resolve(new FTErr(FTErr.NOT_MODIFIED_ERR, source, target, 304, null, error));
    } else {
    // in the other way, try to get response property
        var response = download.getResponseInformation();
        if (!response) {
           resolve(new FTErr(FTErr.CONNECTION_ERR, source, target));
        } 
    }
}

这是我在科尔多瓦的代码:

fileTransfer.download(uri, fileURL, function (entry) {
    console.log('file download successful');
}, function (errorMsg) {
    console.log(errorMsg);
}, false, {
    headers: {"Authorization": authToken},
});`

为了在 Windows 中进行这项工作,我还缺少什么吗?

只需添加,使用 http 下载即可。 自从 ajax 工作以来,Https 证书也有效。

谢谢!

【问题讨论】:

    标签: javascript windows cordova https


    【解决方案1】:

    从 MSDN,BackgroundDownloader 不支持客户端证书。 https://social.msdn.microsoft.com/Forums/en-US/c25146d2-c051-4367-9745-2b526618dc35/winjsxhr-and-httpclient-work-with-client-certificates-backgrounddownloader-doesnt?forum=winappswithhtml5

    所以我想目前唯一的方法是创建一个使用 HttpClient 的插件。

    【讨论】:

      猜你喜欢
      • 2018-02-17
      • 1970-01-01
      • 1970-01-01
      • 2014-10-30
      • 1970-01-01
      • 2021-12-24
      • 1970-01-01
      • 2015-12-04
      • 1970-01-01
      相关资源
      最近更新 更多