put
To upload files to the file storage, use the file/put command.
svc=file/put¶ms={
"itemId": <long>,
"storageType": <uint>,
"path": <text>,
"writeType": <uint>,
"eventHash": <text>
}&sid=<text>
Parameters
Parameter | Description |
itemId | Item ID. |
storageType | Storage type: |
path | Relative path from the root folder to the file. |
writeType | Write type: |
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:
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:
{
"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. |