upload_file

To upload files and get their contents in a session event, use the unit/upload_file method. The method doesn’t save the files to a unit or anywhere else on the server:

Copied!
svc=unit/upload_file&params={
  "eventHash": <text>,
  "toHex": <uint>
}

Parameters

All the parameters are optional. The file itself is required: if the request contains no file, error code 4 is returned.

Parameter Description
toHex Use a bin to string parser: 0 (no), 1 (yes).
eventHash Name of the event that is fired in the session after the files are uploaded. The event contains this name and the contents of each uploaded file (in hexadecimal format if toHex is 1). If the parameter isn’t specified, no event is fired.

Uploading the file

To upload a file, use a POST request with multiple contents (multipart/form-data), where one part contains the parameters and the other contains the file. For example:

Copied!
Request URL: https://hst-api.wialon.com/wialon/ajax.html?svc=unit/upload_file&sid=SESSION_IDENTIFIER
Request Method: POST
Connection: keep-alive
Content-Length: 1901
Cache-Control: no-cache
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryhAXcAjtvh1D61XpC
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/ *;q=0.8
Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.3
Accept-Encoding: gzip,deflate,sdch
Accept-Language: ru,en-US;q=0.8,en;q=0.6
 
------WebKitFormBoundaryhAXcAjtvh1D61XpC
Content-Disposition: form-data; name="params"
 
{"eventHash":"jUploadForm1372772377019","toHex":1}
------WebKitFormBoundaryhAXcAjtvh1D61XpC
Content-Disposition: form-data; name="file"; filename="file.zip"
Content-Type: application/zip
 
 
------WebKitFormBoundaryhAXcAjtvh1D61XpC--

Response

If the request is completed successfully, an empty object is returned:

Copied!
{}

To make sure the file has been uploaded, use the requests/avl_evts method.

If the request fails, error code 4 is returned, indicating that the request contains no file.

If you find a mistake in the text, please select it and press Ctrl+Enter.