File upload using cordova-plugin-file-transfer not working on Android devices - works only on iOS devices

Hello. Does anyone have any idea what might be the problem? For the last weeks i’ve been trying to figure out why my code works only on iOS and not on Android devices. Any idea would be higtly appreciated since i run out of options.

On the android device it shows to send the file but on the server i don’t recive any informations (nor the picture neither the rest of the parameters). On the other hand on iOS all works just fine, and the server also.

My code:

<button ion-button color="dark" (click)="takePhoto()">Open camera </button>
<img [src]="imageURL" *ngIf="imageURL" />
<br><button ion-button color="dark" (click)="upload()">Upload</button>

> import { Component } from ‘@angular/core’;
> import { NavController } from ‘ionic-angular’;
> import { Camera } from ‘ionic-native’;
> import { Transfer } from ‘ionic-native’;

      selector: 'page-home',
      templateUrl: 'home.html'
export class HomePage {
    imageURL: any;
    myInput: string;
    cameraUrl: string;

    constructor(public navCtrl: NavController) {

       Camera.getPicture().then((imageData) => {
            this.imageURL = imageData;
       }, (err) => {
       var ft = new Transfer();
       var options = {
       fileKey: 'file',
       fileName: 'filename.jpg',
       .then((data) => {
            // success
            alert("Image send:"+this.imageURL);
        }, (err) => {
          // error
          alert("err: "+JSON.stringify(err));

I’ve checked the errors in two ways:

Case 1:

I have 2 alerts in my uploaded code:
a. a message in case of success: alert(“image send:”+this.imageURL);
b. a message for error: alert("err: "+JSON.stringify(err));

In my case, I noticed that only the first message appears, the one where
the code is executed correctly.

Case 2:

I’ve connected my phone through cable to the laptop.
To launch the app I typed in “Node.js-Command-Prompt” the command “ionic run
I’ve opened Chrome browser and typed in the address bar
"chrome://inspect/#devices". Then select “INSPECT-option” for my app and
popup the console. The console didn’t show any error.
Is this the right way to test it, or should I try something different?

I printed the object “data” received in case of success for "ft.upload"
function. The result are:


For me this means that information is sent to the server.

One more thing:

  • I’ve run different kinds of tests: sending information to both servers
    with HTTPS and HTTP
  • I’ve tried adding the trustAllHosts=true and in another test

And every time the same problem: works on iOS but fails on android

Details about the solution:

Hello could you please explain how you get the image in the server side because I have the same problem and even with chunkedMode: false I still can’t get the image in the server !!

This exemple, with chunkedMode: false works for me

Let me know if it works for you too

As far as I know, it wont work on android because of permission issues. Hence you need to copy the image to a folder before making reference to it. You can use platform to check if you are on android or ios.

I have a blog post on this here

Hope that helps

I just updated the above link.

Great Solution you save me , Barakallah