UploadRawData
Synchronously uploads images as binary data.
Input data
The input data structure in JSON is shown below.
{
"method": "AdImage",
"param": {
/* AdImageRequest */
"Action": (string),
"AdImageRawData": [
{ /* AdImageRaw */
"Login": (string),
"RawData": (string),
"Name": (string)
}
...
]
}
}
Parameters are described below.
Parameter |
Description |
Required |
AdImageRequest object |
||
|
Action: UploadRawData. |
Yes |
|
Array of |
Yes |
AdImageRaw object |
||
|
Username of the client who owns the image. For advertisers, this parameter is ignored. |
For agencies |
|
Data in base64 encoding. The string can contain a maximum of 20,000,000 characters. |
Yes |
|
Caption for the image. |
Yes |
Output data
The output data structure in JSON is shown below.
{
"data": {
/* AdImageResponse */
"ActionsResult": [
{ /* AdImageActionResult */
"AdImageHash": (string),
"Errors": [
{ /* Error */
"FaultCode": (int),
"FaultString": (string),
"FaultDetail": (string)
}
...
],
}
...
]
}
}
Parameters are described below.
Parameter |
Description |
AdImageResponse object |
|
|
An array consisting of a single
|
AdImageActionResult object |
|
|
Hash of the image. This parameter is returned if the image was uploaded successfully. |
|
Array of |
Error object |
|
|
Error code. |
|
Textual message about the error. |
|
Detailed description of the reason for the error. |
Examples of input data
Python
{
'Action': 'UploadRawData',
'AdImageRawData': [
{
'Login': 'agrom',
'RawData': 'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAA...',
'Name': u'Elephants: new collection'
}
]
}
PHP
array(
'Action' => 'UploadRawData',
'AdImageRawData' => array(
array(
'Login' => 'agrom',
'RawData' => 'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAA...',
'Name' ='Elephants: new collection'
)
)
)
Perl
{
'Action' => 'UploadRawData',
'AdImageRawData' => [
{
'Login' => 'agrom',
'RawData' => 'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAA...',
'Name' ='Elephants: new collection'
}
]
}
Examples of base64 encoding
Python
import base64;
encoded_image = open("/path/to/image.jpg", "rb").read().encode("base64")
PHP
$encoded_image = base64_encode(file_get_contents("/path/to/image.jpg"));
Perl
use MIME::Base64;
open (IMAGE, "/path/to/image.jpg");
my $bin_image = do{ local $/ = undef; <IMAGE>; };
my $encoded_image = MIME::Base64::encode_base64($bin_image);