Cordova 文件传输下载 http 状态 401 - 仅限 ANDROID

arc*_*czi 6 android file-transfer cordova-plugins

我正在尝试从我的 phonegap cordova 应用程序中的服务器下载文件。函数看起来像这样:

fileTransfer.download(uri, localPath, success_callback, error_callback, true, { 'headers': {Connection: "close"}, 'chunkedMode': 'false' });
Run Code Online (Sandbox Code Playgroud)

在我的 error_callback 函数中,我得到:

错误:下载错误来源:http
://xxx.pl/media/images/file_name.png
错误:下载错误目标:file:///storage/emulated/0/imgcache//44b337d46e8bdc29d9bccd6499c54860eb348990.png错误:下载错误代码: 3 http_status: 401

相同的代码在 iOS 上正常工作。此外,如果我尝试像这样直接从服务器显示图像:<img src="http://xxx.pl/media/images/file_name.png">它也可以正常工作。

在我的 config.xml 我有:<access origin="*" />
Cordova 版本:3.4.1-0.1.0
PhoneGap 版本:4.2.0-0.24.2

M. *_*aat 5

我有类似的 401 问题,我需要添加

$ cordova plugin add cordova-plugin-whitelist
Run Code Online (Sandbox Code Playgroud)

到我的应用程序,然后添加这些

<access origin="*" subdomains="true" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
Run Code Online (Sandbox Code Playgroud)

到 config.xml。这解决了我的问题。

希望能帮助到你。