---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.com/dev/direct/doc/dg-v4/en/live/AdImage_UploadRawData.md
  - https://yandex.com/dev/direct/doc/dg-v4/ru/live/AdImage_UploadRawData.md
  - href: en/live/AdImage_UploadRawData.md
    type: text/markdown
    title: Markdown version
  - href: ../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/direct/doc/dg-v4/en/llms.txt

# UploadRawData
Synchronously uploads images as binary data.
## Input data

The input data structure in JSON is shown below.

```javascript
{
   "method": "AdImage",
   "param": {
      /* AdImageRequest */
      "Action": (string),
      "AdImageRawData": [
         {  /* AdImageRaw */
            "Login": (string),
            "RawData": (string),
            "Name": (string)
         }
         ...
      ]
   }
}
```

Parameters are described below.


#|
||
**<sup >Parameter</sup>**
|
**<sup >Description</sup>**
|
**<sup >Required</sup>**
||

||
**<sub >AdImageRequest object</sub>**
||
||
`Action`
|
Action: UploadRawData.
|
Yes
||
||
`AdImageRawData`
|
Array of `AdImageRaw` objects (no more than 10) containing the image to upload.
|
Yes
||

||
**<sub >AdImageRaw object</sub>**
||
||
`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.

```javascript
{
   "data": {
      /* AdImageResponse */
      "ActionsResult": [
         {  /* AdImageActionResult */
            "AdImageHash": (string),
            "Errors": [
               {  /* Error */
                  "FaultCode": (int),
                  "FaultString": (string),
                  "FaultDetail": (string)
               }
               ...
            ],
         }
         ...
      ]
   }
}
```

Parameters are described below.


#|
||
**<sup >Parameter</sup>**
|
**<sup >Description</sup>**
||

||
**<sub >AdImageResponse object</sub>**
||
||
`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.
||

||
**<sub >AdImageActionResult object</sub>**
||
||
`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.
||

||
**<sub >Error object</sub>**
||
||
`FaultCode`
|
Error code.
||
||
`FaultString`
|
Textual message about the error.
||
||
`FaultDetail`
|
Detailed description of the reason for the error.
||
|#

## Examples of input data

# Python

```python
{
   'Action': 'UploadRawData',
   'AdImageRawData': [
      {
         'Login': 'agrom',
         'RawData': 'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAA...',
         'Name': u'Elephants: new collection'
      }
   ]
}
```

# PHP

```php
array(
   'Action' => 'UploadRawData',
   'AdImageRawData' => array(
      array(
         'Login' => 'agrom',
         'RawData' => 'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAA...',
         'Name' ='Elephants: new collection'
      )
   )
)
```

# Perl

```perl
{
   'Action' => 'UploadRawData',
   'AdImageRawData' => [
      {
         'Login' => 'agrom',
         'RawData' => 'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAA...',
         'Name' ='Elephants: new collection'
      }
   ]
}
```

## Examples of base64 encoding

# Python

```python
import base64;
encoded_image = open("/path/to/image.jpg", "rb").read().encode("base64")
```

# PHP

```php
$encoded_image = base64_encode(file_get_contents("/path/to/image.jpg"));
```

# Perl

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

