Table of Contents

Trailers: upload/delete image

To upload an image for a trailer, use the command resource/upload_trailer_image:

svc=resource/upload_trailer_image&params={"itemId":<long>,
					  "trailerId":<long>,
					  "eventHash":<text>}

:!: To delete an image, use the command Trailers: create, edit, delete.

Parameters

Name Description
itemId resource ID
trailerId trailer ID
eventHash name of event, which will be generated after uploading the image (optional parameter)

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

For example:

Request URL:https: //hst-api.wialon.com/wialon/ajax.html?svc=resource/upload_trailer_image&sid=8157df114c0e601f0f31091c3c2ac53d
Request Method: POST
Host: hst-api.wialon.com
Connection: keep-alive
Content-Length: 31756
Cache-Control: no-cache
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryLjl26xgAWBYzO713
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

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

{"itemId":717314,"trailerId":6,"eventHash":"jUploadForm1372768935931"}
------WebKitFormBoundaryLjl26xgAWBYzO713
Content-Disposition: form-data; name="eventHash"

jUploadForm1372768935931
------WebKitFormBoundaryLjl26xgAWBYzO713
Content-Disposition: form-data; name="trailers_dlg_props_upload_image"; filename="image.jpg"
Content-Type: image/jpeg


------WebKitFormBoundaryLjl26xgAWBYzO713--

Response

{}	/* empty object if execution successful, if not - error code */

To be sure that the image has been uploaded, you can execute the command Events:

{
	"tm":<uint>,				/* current server time (UTC) */
	"events":[
		{
			"i":<long>,			/* trailer ID (-1 if unknown) */
			"d":{				/* data */
				"hash":<text>		/* upload is complete */
			}
		}
	]
}