Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-12392

[android] file-transfer uploads 13 bytes less than total

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • None
    • None
    • None
    • Samsung j5, Android 5.0, cordova-plugin-file-transfer@1.5.1

    Description

      Reported on Slack

      File transfer plugin uploads the file content 13bytes less the total size of the file:

       document.addEventListener('deviceready',DeviceReady, false);
              var image = document.getElementById("image");
              var upload = document.getElementById("upload");
              var showing = document.getElementById("showing");
              function DeviceReady(){
                  console.log("trying out the camera things here");
              }
              //this function is invoked when the user clicks the button  
              function getImage(){
                  image.style.display="none";
                  navigator.camera.getPicture(
                          onSuccess,
                          onFail,
                          {
                          quality: 100,
                          destinationType:navigator.camera.DestinationType.FILE_URI,
                          sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
                  });
              }
              function onSuccess(imageURI){
                  image.src=imageURI;
                  image.style.display="block";
                  var serverUrl = encodeURI("http://192.168.43.146/filetransfer");
                  var options = new FileUploadOptions();
                  options.fileKey="file";
                  options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
                  options.mimeType="image/jpeg";
                  var params = new Object();
                  params.value1 = "test";
                  params.value2 = "param";
                  options.params = params;
                  options.chunkedMode = false;
                  options.multipartMode = true;
                  var ft = new FileTransfer();
                  ft.onprogress = function(progressEvent) {
                  if (progressEvent.lengthComputable) {
                  showing.innerHTML = (progressEvent.loaded / progressEvent.total)*100;
                  } else {
                  loadingStatus.increment();
                  }
                  };
                  ft.upload(imageURI, serverUrl, onUploadSuccess, onUploadError, options, true);
              }
              function onFail(message){
                  showing.innerHTML = "showing image failed "+ message;
              }
              function onUploadSuccess(r){
                      showing.innerHTML = "Uploaded successfully";
                      showing.innerHTML =  "Code = " + r.responseCode +"Response = " + r.response+ "Sent = " + r.bytesSent;
              }
              function onUploadError(){
                      showing.innerHTML = "Error uploading file";
              }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            daserge Sergey Shakhnazarov
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: