UploadImage
Definition
Use this call to upload a single image file and accept binary stream with file content. Allowed image formats are JPG and PNG. The maximum size of an image file is 1MB.
Request URI: https://api.sellercenter.lazada.sg?Action=UploadImage
Parameters
Field | Type | Description |
---|---|---|
Action | string | UploadImage Name of the API that is to be called. Mandatory. |
Format | string | The response format, with XML as the default. Can be XML or JSON. Optional. |
Timestamp | datetime | The current time in ISO8601 format (e.g., Timestamp=2016-04-01T10:00:00+02:00 for Berlin). Mandatory. |
UserID | string | The ID of the user making the call. Mandatory. |
Version | string | The API version against which this call is to be executed. The current version is "1.0". Mandatory. |
Signature | string | The cryptographic signature, authenticating the request. You must create this value by computing the SHA256 hash of the request, using the API key of the user specified in the UserID parameter. Mandatory. |
Request body
Body contains binary image content.
Code sample
# UploadImage cURL example. to run, update Timestamp and recompute Signature
#
url = "https://api.sg.ali-lazada.com/"
post
data-urlencode Action=UploadImage
data-urlencode Timestamp=2016-07-18T11:11+0000
data-urlencode [email protected]
data-urlencode Version=1.0
data-urlencode Signature=9ade00fb4b9ab9ed1b8a4d189f1a13e1029edc25dd963235480ec69226fd9f39
data-urlencode image=@/tmp/image-file.jpg
//construct request with local file
File image = new File("/Users/yucheng/Desktop/google-search.png");
UploadImage uploadImage = new UploadImage(image);
try {
ModifyImageResponse response = uploadImage.execute();
System.out.println("New Url: " + response.getBody().getImage().getUrl());
System.out.println("HashCode: " + response.getBody().getImage().getCode());
} catch (LazadaException e) {
System.out.println(e.getResponseStr());
}
Response
The response body contains an image resource, which is composed of the following fields:
Name | Type | Description |
---|---|---|
Url | string | The URL address of the uploaded image. |
Code | string | The hash code of the image. |
Result sample
Success response is as follows.
<?xml version="1.0" encoding="UTF-8"?>
<SuccessResponse>
<Head>
<RequestId/>
<RequestAction>UploadImage</RequestAction>
<ResponseType>Image</ResponseType>
<Timestamp>2016-07-07T20:12:14+0700</Timestamp>
</Head>
<Body>
<Image>
<Url>http://my-live-01.slatic.net/p/orange_yellow.jpg</Url>
<Code>61bdf049525b7d4c2cf79257ec7c2c56</Code>
</Image>
</Body>
</SuccessResponse>
{
"SuccessResponse": {
"Head": {
"RequestId": "",
"RequestAction": "UploadImage",
"ResponseType": "Image",
"Timestamp": "2016-08-25T11:26:32+0000"
},
"Body": {
"Image": {
"Url": "https//sg.s.alibaba.lzd.co/original/52e91dc864f193c6a096816a0ac1b6d0.jpg",
"Code": "52e91dc864f193c6a096816a0ac1b6d0"
}
}
}
}
Error messages
Error code | Message |
---|---|
30 | E030: Empty Request |
300 | E300: Upload Image Failed |
303 | E303: The image is too large |
1000 | Internal Application Error. |
Updated almost 7 years ago