3

I'm working on uploading image as base64 image stream from phonegap/cordova application, it works perfectly fine in Android but not working in ios, however in ios it works when the image is as png/jpg but when it is as base64 image stream its not working, Please can anybody help me out with the same.

Here is my code for the same,

var options = new FileUploadOptions();
    options.fileKey = "file";   
    options.fileName = "test.jpg";
    options.mimeType = "image/jpeg";    
    options.chunkedMode = false;

     options.params = {
                "key": "test.jpg",
                "AWSAccessKeyId": awsKey,
                "acl": acl,
                "policy": policyBase64,
                "signature": signature,
                "Content-Type": ""
            };

    var ft = new FileTransfer();
    ft.upload(imageURI, s3URI + "",
            win, fail, options);
}
function win(r) {
    console.log("Code = " + r.responseCode);
    console.log("Response = " + r.response);
    console.log("Sent = " + r.bytesSent);
    alert(r.response);
}
function fail(error) {
    alert("An error has occurred: Code = " + error.code);
}
Mayuri Ruparel
  • 694
  • 2
  • 11
  • 36
  • if you are using the base64, why don't you just use a simple AJAX POST? – jcesarmobile Jan 12 '15 at 07:48
  • What error do you get? – Emre Jan 12 '15 at 09:00
  • @jcesarmobile In my app its sometimes base64 while some times its jpg/png its conditions based, hence I opted for FileTransfer, it really works well at android side and ios side too for jpg/png – Mayuri Ruparel Jan 12 '15 at 09:42
  • 2
    @Emre: I get the error, Error Code 1 which says file not found only for base64 ios, In Android it works perfectly fine for base64 and png/jpg and in ios also it works fine for jpg/png but for base64 it gives File Transfer failed with Error Code 1 which says file not found – Mayuri Ruparel Jan 12 '15 at 09:44
  • @MayuriRuparel, How did you upload base64 image using cordova-plugin-file-transfer in Android? I'm [trying to do this](http://stackoverflow.com/questions/37063410/cant-upload-base64-image-using-cordova-plugin-file-transfer/37071410?noredirect=1#comment61690633_37071410) and it's not working :/ – Vinícius Mendes de Souza May 06 '16 at 14:26

3 Answers3

1

Version 1.5.0 of the file transfer plugin has already added that functionality. The patch was applied 14 Dec 2015.

You can see the commit here.

Upgrading the plugin solved the problem in my case at least.

maltalk
  • 156
  • 1
  • 7
0

Set chunkMode true when use base64 for upload using phonegap

masadi zainul
  • 397
  • 4
  • 14
0

I set chunkMode true but still file is not transferring on server .It seems that cordova file transfer plugin does not support base64 image for upload on iOS.

Gokrazee
  • 81
  • 1
  • 7