put

To upload files to the file storage, use the file/put command.

Copied!
svc=file/put&params={
"itemId": <long>,
"storageType": <uint>,
"path": <text>,
"writeType": <uint>,
"eventHash": <text>
}&sid=<text>

Parameters

Parameter

Description

itemId

Item ID.

storageType

Storage type:
1  public (all users can see and download
files);
2  protected (only users with access rights can see and download
files)

path

Relative path from the root folder to the file.

writeType

Write type:
0  overwrite the file,
1  append to the file content,
2  don't overwrite if the file exists.

eventHash

Name of the event which will be generated after processing the data.

A file mustn’t have the same name as a folder.

To upload multiple files, send them using a POST request with parameters (multipart/form-data). For example:

Copied!
Request URL: https://hst-api.wialon.com/wialon/ajax.html?svc=file/put
Request Method: POST
Connection: keep-alive
Content-Length:333998
Cache-Control:max-age=0
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryMpLUirMexsfCGaJP
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


------WebKitFormBoundaryhJ0ZukEcpN7MgFnC
Content-Disposition: form-data; name="params"

{"itemId":439,"storageType":"1","path":"1","writeType":0,"eventHash":"jUploadForm1414572405484"}
------WebKitFormBoundaryhJ0ZukEcpN7MgFnC
Content-Disposition: form-data; name="eventHash"

jUploadForm1414572405484
------WebKitFormBoundaryhJ0ZukEcpN7MgFnC
Content-Disposition: form-data; name="f"; filename="one-file"
Content-Type: application/octet-stream


------WebKitFormBoundaryhJ0ZukEcpN7MgFnC--

Response

If the request is completed successfully, the following response is returned:

Copied!
{
  "error":0
}

If the request is not completed, an error code is returned.

Error codes

Code Description
1 User not authorized.
4 Invalid input parameters.
7 Insufficient rights to the item specified in the itemId parameter.
Download PDF file
Download Word document

See also