I've got a strange issue with fileTransfert plugin of cordova (Target device is Android 4.3 and it works on Android 6.0). I just arrive to upload one file on two. The first and third sending work well, but the second returns an error code 3 with this error message in logs:
E/FileTransfer(15179): {"target":"https:\/\/XXXX\/uploadTeamPicture","http_status":0,"code":3,"source":"file:\/\/\/storage\/emulated\/0\/Pictures\/2017_4_14\/XXXXX_14-15-00.jpeg","exception":"Write error: ssl=0x6e653128: I\/O error during system call, Broken pipe"}
This is the function
// Manage File sending
function uploadFile(webAddr,fileURL,params)
{
// when it's finished
var win = function (r) {
alert("Picture has been sent correctly !","Information");
$("#takePicture").hide();
resetAppli();
fileTrans.abord();
};
// if upload failed
var fail = function (error) {
var msg="Please take another picture \n";
msg+="An error has occurred: Code = " + error.code;
msg+="\n src:"+error.source;
msg+="\n trgt:"+error.target;
alert(msg);
$("#takePicture").hide();
resetAppli();
};
var uri = encodeURI(webAddr);
var options = new FileUploadOptions();
options.fileKey="fileToUpload";
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
options.mimeType="text/plain";
var headers={'headerParam':'headerValue'};
options.headers = headers;
options.params = params;
//var ft = new FileTransfer();
var ft=fileTrans;
ft.onprogress = function(progressEvent) {
if (progressEvent.lengthComputable) {
//loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
uploadProgress(progressEvent);
var infoProg=(progressEvent.loaded / progressEvent.total);
console.log("Progress :" + infoProg);
} else {
//loadingStatus.increment();
}
};
// init progress bar before sending
initProgressBar();
// send file
ft.upload(fileURL, uri, win, fail, options);
}
If somebody has an idea ... Many Thanks for your help
Find the solution here : Code 3 when uploading file to S3 using FileTransfer in Phonegap on Android 4.3
Just add true option at the end of parameters table.