Mayuri Ruparel
Mayuri Ruparel

Reputation: 694

Phonegap / Cordova File Transfer Upload Image as Base64 String not working in ios

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);
}

Upvotes: 3

Views: 3338

Answers (3)

maltalk
maltalk

Reputation: 156

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.

Upvotes: 1

Gokrazee
Gokrazee

Reputation: 81

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.

Upvotes: 0

masadi zainul
masadi zainul

Reputation: 397

Set chunkMode true when use base64 for upload using phonegap

Upvotes: 0

Related Questions