upload_zone_image
The upload_zone_image method is used to attach an image to a geofence as well as to copy an image from one geofence to another.
svc=resource/upload_zone_image¶ms={"itemId":<long>,
"id":<long>,
"eventHash":"<text>",
"oldItemId":<long>,
"oldZoneId":<uint>}
&sid="<text>"
To delete an image, use the update_zone method.
To get an image, use the avl_zone_image method.
Parameters
| Name | Description |
|---|---|
| itemId | Resource ID. |
| id | Geofence ID. |
| eventHash | The event name which should be generated after uploading the image. |
| oldItemId | The resource ID of the geofence the image of which should be applied. Optional parameter. |
| oldZoneId | The ID of the geofence the image of which should be applied. Optional parameter. |
To upload an image, use a POST request with multiple parameters (multipart/form-data), where one part contains parameters and the other contains the image.
Example:
Request URL: https://hst-api.wialon.com/wialon/ajax.html?svc=resource/upload_zone_image
Request Method: POST
Host: hst-api.wialon.com
Connection: keep-alive
Content-Length: 31753
Cache-Control: no-cache
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryX2W1y7AVnQkXQAM0
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
------WebKitFormBoundaryX2W1y7AVnQkXQAM0
Content-Disposition: form-data; name="params"
{"itemId":717314,"id":1,"eventHash":"jUploadForm1372768029714"}
------WebKitFormBoundaryX2W1y7AVnQkXQAM0
Content-Disposition: form-data; name="eventHash"
jUploadForm1372768029714
------WebKitFormBoundaryX2W1y7AVnQkXQAM0
Content-Disposition: form-data; name="zone_create_upload_image"; filename="zZeVUgLEJXE.jpg"
Content-Type: image/jpeg
------WebKitFormBoundaryX2W1y7AVnQkXQAM0--
It is also possible to copy an image from one geofence to another. To do it, execute a request without an image, but with the oldItemId and oldZoneId fields.
Returned result
If the request is successful, an empty JSON is returned.
{ }
If not, an error code is returned. Possible error codes:
| Code | Description |
|---|---|
| 7 | The resource doesn’t exist, the user doesn’t have the Create, edit, and delete geofences access right to it, or, when copying the image from another geofence, the resource with the oldItemId doesn’t exist, the user doesn’t have the View geofences access right to it, or the geofence with the oldZoneId isn’t found. |
| 6 | Undefined error. |
| 4 | Wrong input parameters. |
To make sure that the image has been uploaded, execute the avl_evts request:
{
"tm":<uint>, /* current server time (UTC) */
"events":[
{
"i":<long>, /* geofence ID (-1 if unknown) */
"d":{ /* data */
"hash":"<text>" /* the uploading is complete */
}
}
]
}