upload_trailer_image

The upload_trailer_image function is used to attach an image to a trailer.

Copied!
svc=resource/upload_trailer_image&params={"itemId":<long>,
					  					  "trailerId":<long>,
					  					  "eventHash":"<text>",
										  "oldItemId":<long>,
										  "oldTrId":<uint>}
                                 &sid="<text>"

Parameters

NameDescription
itemIdResource ID.
trailerIdTrailer ID.
eventHash

The name of the event which should be generated after attaching the image. Optional parameter. 

oldItemIdThe resource ID from which the trailer image should be copied. Optional parameter.
oldTagIdThe trailer ID the image of which should be copied. Optional parameter.

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

Example:

Copied!
Request URL:https: //hst-api.wialon.com/wialon/ajax.html?svc=resource/upload_trailer_image
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--

It is also possible to copy an image from another trailer. To do this, execute a request with no image but with the oldItemId and oldTagId fields.

Returned result

If the request is successful, an empty JSON is returned.

Copied!
{ }

If not, an error code is returned. Possible error codes:

CodeDescription
7Failed to fetch the item with the desired ACL (ADF_ACL_AVL_RES_EDIT_TRAILERS) or the item/trailer with the old_id not found (when copying the image from another trailer).
6Undefined error.
4

Wrong input parameters.

To make sure that the image has been uploaded, execute the avl_evts request:

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


Download PDF file
Download Word document

See also