hey there,
in my ionic application I always get an error trying to download a pdf document from our server using the cordova file transfer plugin:
public getDocument(url: string, filePath: string, fileName: string): Promise<boolean> {
const fileTransfer = new Transfer();
let headers = this.createHeader();
let requestOptions = new RequestOptions({headers: headers});
return this.documentPromise = new Promise((resolve, reject) => {
fileTransfer.download(url, filePath + fileName, true, requestOptions)
.then((entry) => {
resolve(entry.toURL());
})
.catch((error) => {
reject(error);
});
It jumps directly into the catch case and gives the following error:
JSON.stringify(error)
>> "code": 3, "source": "http://...", "target": file:///...", "http_status": null, "body": null, "exception": "Handshake failed"
the “source” path looks like “asd.mysite.de/proxy/bill/app/pdfdocument”; and the file is reachable and downloadable from other devices. The “target” path looks like “file:///storage/emulated/0/Android/data/subdomain.domainnam‌​e.toplevdomain/files‌​/document.pdf”. On my phone by now there exists the path “/storage/emulated” and the rest of the path is never created.
This only happens on my Samsung A3, but not on other android phones or ios.
Any ideas on why this error might occur?
This is my running system:
cli packages: (D:\Users\...)
@ionic/cli-utils : 1.9.2
ionic (Ionic CLI) : 3.9.2
global packages:
Cordova CLI : 7.0.1
local packages:
@ionic/app-scripts : 2.1.3
Cordova Platforms : android 6.2.3 browser 4.1.0
Ionic Framework : ionic-angular 3.6.0
System:
Android SDK Tools : 26.0.2
Node : v6.11.0
npm : 5.3.0
OS : Windows 7
The relevant plugins are set with this version:
"cordova-plugin-file": "^4.3.3",
"cordova-plugin-file-opener2": "^2.0.19",
"cordova-plugin-file-transfer": "^1.6.3",
"cordova-plugin-whitelist": "^1.3.1",