You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Sergey Shakhnazarov (JIRA)" <ji...@apache.org> on 2017/01/25 13:47:26 UTC

[jira] [Created] (CB-12392) [android] file-transfer uploads 13 bytes less than total

Sergey Shakhnazarov created CB-12392:
----------------------------------------

             Summary: [android] file-transfer uploads 13 bytes less than total
                 Key: CB-12392
                 URL: https://issues.apache.org/jira/browse/CB-12392
             Project: Apache Cordova
          Issue Type: Bug
          Components: Plugin File Transfer
         Environment: Samsung j5, Android 5.0, cordova-plugin-file-transfer@1.5.1
            Reporter: Sergey Shakhnazarov


Reported on Slack

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

{code}
 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";
        }
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org