Access server response in uploader with autosend: true

Is it possible to access server response in uploader with ‘autosend: true’ ?

You can use onFileUpload event.

Second parameter - server side response

Is this the right way?


  webix.ui({
    id:   'ed_file_upload',
    view: 'uploader',
    autosend: true,
    upload: proc.request_url,
    formData:{
       action: 'data_file_upload'
    },
    link:'uploaded_data_files',
    apiOnly:true,
  });

  // Init file upload dropzone.
  setTimeout(function () {
    $$('ed_file_upload').addDropZone($$('main_view').$view);
  }, 100);

  $$('ed_file_upload').attachEvent('onFileUpload', function(a, b, c, d) {
    console.log('poplopgop!');
    console.log('a: ' + a);
    console.log('b: ' + b);
    console.log('c: ' + c);
    console.log('d: ' + d);
  });

File is uploaded, action parameter is sent, but console is empty as if ‘onFileUpload’ is never triggered.

onFileUpload will fire only if upload operation has a valid response from server side. There is a pair onFileUploadError event which will fire in case of uploading error. It has same parameters.

Can you check, what is the server side response for the file uploading operation ?

As described here:
http://docs.webix.com/desktop__uploader_serverside.html#tuningserversideresponse

Added ‘status’ key with value ‘server’ to server response.
‘onFileUpload’ event is now triggered.

I thought it would trigger without that…

Thanks!

Uploader must fire onFileUpload event for any valid json response

Well, it didn’t.
Example server response, ‘onFileUpload’ event is not triggered:


{
   "price_data_import_result" : "Location: ZELANO/Shavyrin Terminal\
NOTE: Import complete: 36 items (36 buyers, 16 sellers) for 1 stations in 1 systems"
}

Adding 1 more key fixes the issue, ‘onFileUpload’ is triggered:


{
   "status" : "server",
   "price_data_import_result" : "Location: ZELANO/Shavyrin Terminal\
NOTE: Import complete: 36 items (36 buyers, 16 sellers) for 1 stations in 1 systems"
}

I’m afraid that it’s a bug :frowning:

Sorry, you are right. The event will be triggered only when response has status:“server”

We will update documentation and will consider changing the code to trigger this event on any valid json response.

I don’t think this has been fixed as of version 2.5.14