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

Action: UploadRawData.

Yes

AdImageRawData

Array of AdImageRaw objects (no more than 10) containing the image to upload.

Yes

AdImageRaw object

Login

Username of the client who owns the image.

For advertisers, this parameter is ignored.

For agencies

RawData

Data in base64 encoding. The string can contain a maximum of 20,000,000 characters.

Yes

Name

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

ActionsResult

An array consisting of a single AdImageActionResult object, which contains the result of image uploading:

  • The AdImageHash, if uploading was successful.
  • The Errors array, if an error occurred.

AdImageActionResult object

AdImageHash

Hash of the image. This parameter is returned if the image was uploaded successfully.

Errors

Array of Error objects with errors that occurred while uploading images.

Error object

FaultCode

Error code.

FaultString

Textual message about the error.

FaultDetail

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);