Edmund Wong
Posts: 0
Joined: Wed Feb 25, 2015 10:40 pm

no callback after FileTransfer upload

Below is the code I use to upload some image file to our server:

SP_mobileAPI.win = function(r) {
this.onLogMsg('uploadImage success: response = ' + r.response);

Code: Select all

     }; 
 SP_mobileAPI.fail = function(error) { 
      this.onLogMsg('uploadImage fail: code = ' + error.code); 

    }; 

 SP_mobileAPI.onprogress = function(p) { 
     this.onLogMsg('upload progress: ' + p.loaded + '/' + p.total); 
 }; 

 SP_mobileAPI.uploadImage = function(imageURI) { 

     var headers = { 
         'Authorization': 'XXX'            
     }; 

     try { 
         var options = new FileUploadOptions(); 
         options.fileKey = "file-upload-input"; 

         options.fileName = ""; 
         options.mimeType =  'image/jpeg'; 
         options.headers = headers; 

         var uri = encodeURI(SP_mobileSettings.clientWebServerUrl  ); 
         var ft = new FileTransfer(); 
         ft.onprogress = this.onprogress; 
         ft.upload(imageURI, uri, this.win, this.fail, options, true); 

     } catch(err) { 
         this.onLogMsg('exception:' + err.message); 
     } 

 }; 

The problem is none of the callback functions (success, fail or onprogress) is ever called. I am running on Android 4.4.2

Return to “Issues”