Closed kefahB closed 6 years ago
You can try adding the user data to the header
import { isIOS } from "tns-core-modules/platform";
declare var NSString: any;
declare var NSUTF8StringEncoding: any;
declare var java: any;
declare var android: any;
export function base64Encode(value) {
if (isIOS) {
let text = NSString.stringWithString(value);
let data = text.dataUsingEncoding(NSUTF8StringEncoding);
return data.base64EncodedStringWithOptions(0);
} else {
let text = new java.lang.String(value);
let data = text.getBytes("UTF-8");
return android.util.Base64.encodeToString(data, android.util.Base64.DEFAULT);
}
}
const auth = {"Authorization": base64Encode(`Basic ${user_name}:${password}`};
this.downloadManager.createDownload({
...
headers: auth
});
Hello @triniwiz , I'm sorry but the problem persists with android !
The structure on remote
www
|___ books
|___ 1094343-9
|___ 1094343-9.zip
|___ .htaccess
|___ .htpasswd
Hello @triniwiz https://github.com/triniwiz , I'm sorry but the problem persists with android !
The structure on remote
www | books | 1094343-9 | 1094343-9.zip | .htaccess |___ .htpasswd
2018-01-30 23:07 GMT+01:00 Osei Fortune notifications@github.com:
You can try adding the user data to the header
import { isIOS } from "tns-core-modules/platform"; declare var NSString: any;declare var NSUTF8StringEncoding: any;declare var java: any;declare var android: any; export function base64Encode(value) { if (isIOS) { let text = NSString.stringWithString(value); let data = text.dataUsingEncoding(NSUTF8StringEncoding); return data.base64EncodedStringWithOptions(0); } else { let text = new java.lang.String(value); let data = text.getBytes("UTF-8"); return android.util.Base64.encodeToString(data, android.util.Base64.DEFAULT); } } const auth = {"Authorization": base64Encode(
Basic ${user_name}:${password}
}; this.downloadManager.createDownload({ ... headers: auth });— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/triniwiz/nativescript-downloader/issues/7#issuecomment-361750722, or mute the thread https://github.com/notifications/unsubscribe-auth/ARTstvlWCemPy_jrVzKqRrr3xeEcQLhVks5tP5KHgaJpZM4Rv5e8 .
--
BADER ALDIN Kefah PHENICIA S.A.R.L 5, Rue André Duchscher L-1424 Luxembourg Portable : 661 46 66 20 / 21 Fixe : 27 84 86 00 Fax: 27 84 86 01 www.phenicia.lu phenicia@pt.lu kefah.bader@gmail.com
@kefahB using auth headers should be fine now
Hello , I need to download a zip file from server whose folder is protected by a .htaccess.
The url is : https://user_name:password@www.test.com/books/1094343-9/1094343-9.zip
The downloader makes a fictitious download and in one second to finished but without downloading the file actually.
PS : Is work on ios