File transfer / upload


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) {
                    checkedFile.file(function(file) {

                        console.log('file ',file);
                        var a = new FileReader();
                        options =  {
                            'fileKey': 'file',
                            'chunkedMode': false,
                            'mimeType': file.type,
                            'headers': {
                                'Authorization': 'Basic ' + auth,
                                'X-Update-Nonce': token,
                                "cache-control": "no-cache",
                                'appKey': 'app_20323538_1466692503781',

                            '3rdParty server',
                        ).then(function(result) {
                            console.log('sucesso: ', result);
                        }, function(err) {
                            console.log('erro: ', err);
                        }, function(progress) {
                            console.log('progress: ', progress);

                            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',
                        }).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



Well. well.

I have no idea what is wrong with cordova file, but following this link

I changed to a input file, no more cordova plugins and I was able to upload the image.

The curious is console.log a file from angular seems to have less information than a file from cordova.
Idk what cordova is missing or Angular is adding to make it work.

Thanks anyway everyone who came here.


Just an important update.
I saw alot of people having trouble with fileTransfer.

The code I 1st posted works fine, the problem was with my version of fileTransfer.

Also the solution with input file works fine but without a multi select.

My current plugins / versions involved:

“name”: “cordova-plugin-file-transfer”,
“version”: “1.5.1”,

“name”: “cordova-plugin-file”,
“version”: “4.2.0”,

“name”: “cordova-plugin-image-picker”,
“version”: “1.1.1”,