I belive it is much more a cordova issue than an ionic but, maybe someone had the same issue as me.
Or maybe it is just my code…
I’m using imagePicker to select a image from galery, after I saw some posts saying that, because it creates a tmp image, it causes de issue, so I changed to imagePickerEx, and now I’m trying to upload both images, the copy and the original one.
Also the file transfer
File transfer keeps throwing me error code 1, http status 411,
Error code 1 is file not found, but the paths are right I think, I changed it so many times that I think at least 1 of my tries should be right.
Http 411 is about length header, what if I put it I will get a time out from the server.
With postman chrome extension, I can make the same request im trying in Ionic without problem.
I even tried a normal post, that almost gave me what I need, except I can’t post the real image at request.
My last tries is letting my code inside cordovaFile call, to make sure I have the file…
My code right now…
Any suggestion is welcome, I’m trying for a long time without success.
$cordovaFile.checkFile(path, file).then(function(checkedFile) {
console.log(checkedFile);
checkedFile.file(function(file) {
console.log('file ',file);
var a = new FileReader();
console.log(a.readAsBinaryString(file));
options = {
'fileName': file.name,
'fileKey': 'file',
'chunkedMode': false,
'mimeType': file.type,
'headers': {
'Authorization': 'Basic ' + auth,
'X-Update-Nonce': token,
"cache-control": "no-cache",
'appKey': 'app_20323538_1466692503781',
'Slug': file.name,
}
};
$cordovaFileTransfer.upload(
'3rdParty server',
file.localURL,
options,
true
).then(function(result) {
console.log('sucesso: ', result);
}, function(err) {
console.log('erro: ', err);
}, function(progress) {
console.log('progress: ', progress);
});
$http({
method: 'POST',
url: 3rdParty server,
//data: {'file': {'0': file.localURL}},
data: {'file': file.localURL},
headers: {
'Authorization': 'Basic ' + auth,
'X-Update-Nonce': token,
'appKey': 'app_20323538_1466692503781',
"cache-control": "no-cache",
'Content-Type': 'multipart/form-data; boundary=----',
'Content-Disposition': 'form-data; name="file"; filename=""',
'Content-Type': file.type,
'Connection': 'close',
'Slug': file.name
}
}).success(function (list, status, headers, config) {
console.log('upl sucesso: ', list, status, headers, config);
}).error(function (list, status, headers, config) {
console.log("upl erro: ", list, status, headers, config);
});
});
});
I forgot the say:
Cordova version: 6.2.0
Ionic version: 1.7.16
thanks.