Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova File-Transfer download http status 401 - ONLY ANDROID

I'm trying to download file from server in my phonegap cordova application. Function looks like this:

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

In my error_callback function I get:

ERROR: Download error source: http://xxx.pl/media/images/file_name.png
ERROR: Download error target: file:///storage/emulated/0/imgcache//44b337d46e8bdc29d9bccd6499c54860eb348990.png
ERROR: Download error code: 3 http_status: 401

The same code works properly on iOS. Additionally if I try to display image directly from server like this: <img src="http://xxx.pl/media/images/file_name.png"> it also works properly.

In my config.xml I have: <access origin="*" />
Cordova version: 3.4.1-0.1.0
PhoneGap version: 4.2.0-0.24.2

like image 964
arczi Avatar asked Apr 02 '15 13:04

arczi


1 Answers

I have kind of same 401 problem, i needed to add

$ cordova plugin add cordova-plugin-whitelist

to my app and then adding these

<access origin="*" subdomains="true" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />

to config.xml. This resolved my problem.

Hope it helps.

like image 130
M. Junaid Salaat Avatar answered Sep 20 '22 05:09

M. Junaid Salaat