File Transfer Android returns null

Hi,

I got new blank template. added cordova camera plugin & file transfer plugin. I just added one button that invokes camera and get the picture and upload it server. simple POC.

I am testing this in IONIC VIEW

Everything is working fine in IOS. but In Android it always go to error block and returns a null object
{code:null,source:null,target:null, http_status:null,body:null,exception:null}. I have been struggling with this for last few days. Please help

Code:
addimage() { // invoked from button
let options = {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
// popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false,
correctOrientation: true
};
this.getPicture(options);

}
getPicture(options) {
this.plt.ready().then((readySource) => {
Camera.getPicture(options).then((fileUrl) => {
this.uploadpic(fileUrl);
})
})// end get pic from Camera
}

uploadpic(fileUrl:any) {
let srvrurl = "http://ihandi.com/imageuploads/upload.php"
const fileTransfer = new Transfer();
let options: any;
options = {
fileKey: “file”,
fileName: fileUrl.substr(fileUrl.lastIndexOf(’/’) + 1),
chunkedMode: false,
mimeType:“image/jpeg”,
params : {‘fileName’: fileUrl.substr(fileUrl.lastIndexOf(’/’) + 1)}
};
fileTransfer.upload(fileUrl, encodeURI(srvrurl), options,true)
.then((result: any) => {
alert(‘inside upload’);
alert(result.response);
alert(result.response.url);
let res = JSON.parse(result.response);
this.prdimage = res.url;

    },(err) => {
      alert('Inside error');
      alert(JSON.stringify(err));

});
}

Hi,

I’ve exactly the same problem.
Do you finally find a solution ?

I do not see the Transfer plugin listed in here.

A possible solution is to use base64 encoding.
I was not able to make it work as well so I used base64 (output possible for camera plugin) and it works like a charm

Thanks for the tip. I’m going to test it

But for my understanding, it’s work perfeclty for iOS. How it’s possible if the plugin is not supported by Ionic View ?!

No idea and I had no time to try to figure out. I found another solution and I went.

Good luck and don’t hesitate to tell me if it worked :slight_smile:

@kel, you are exactly right. it’s just not working in IONIC View. it’s working fine after building the app. build your test apk and run on device. it is working fine in app

speedflyer https://forum.ionicframework.com/users/speedflyer
March 6

No idea and I had no time to try to figure out. I found another solution
and I went.

Good luck and don’t hesitate to tell me if it worked [image:
:slight_smile:]

Visit Topic
https://forum.ionicframework.com/t/file-transfer-android-returns-null/77441/6
or reply to this email to respond.

In Reply To
Kel https://forum.ionicframework.com/users/kel
March 5
Thanks for the tip. I’m going to test it But for my understanding, it’s
work perfeclty for iOS. How it’s possible if the plugin is not supported by
Ionic View ?!

Visit Tomic
https://forum.ionicframework.com/t/file-transfer-android-returns-null/77441/6
or reply to this email to respond.

To unsubscribe from these emails, click here
https://forum.ionicframework.com/email/unsubscribe/b29a90a2129eb3eff5277228b5d8764b853dba58ebc84a0dbfc6194d9744f9c3
.