Alipay, China's leading third-party online payment solutionAlipay, China's leading third-party online payment solution

alipay.offline.material.image.upload

Use this interface to upload images or videos, after which, each image or video is then assigned a unique ID. Only with the ID can the image or video be used.

Request

Service address

Environment

HTTPS request URL

Production environment

https://openapi.alipay.com/gateway.do

Request parameters

Parameter

Description

Basic parameter

app_id

String (32) Required

A unique ID that is assigned by Alipay to identify an app

Example:2014072300007148

method

String (128) Required

The interface name

Example:alipay.offline.material.image.upload

format

String (40) 

Request format. Only JSON is supported.

Example:JSON

charset

String (10) Required

The charset with which the request data are encoded. UTF-8, GBK, and GB2312 are supported. 

Example:UTF-8

sign_type

String (10) Required

The signature algorithm used by the merchant to generate the pre-sign string. RSA and RSA2 are supported. RSA2 is preferred.

Example:RSA2

sign

String (344) Required

The signature value. See Signature for details.

Example:2118ac8fad6bc1d9e88a6cd017c18d37

timestamp

String (19) Required

The time when the request is sent. The format is yyyy-MM-dd HH:mm:ss.

Example:2014-07-24 03:07:50

version

String (3) Required

The interface version. The value is fixed as 1.0.

Example:1.0

Business parameter

image_type

String (8) Required

Format of the image or video

Example:JPG or MP4

image_name

String (128) Required

Name of the image or video
Example:Jack

image_content

Byte_array (5.24288e+06Required

Binary data of the image or video. The maximum image file size cannot exceed 5 MB and the maximum video file size cannot exceed 50 MB. 

Response

Parameter

Description

Basic parameter

code

String Required

Gateway return code, which indicates whether the request is accepted by Alipay gateway.

Example:40004

msg

String Required

Description of the gateway return code

Example:Business Failed

sub_code

String

Processing result of the request

Example:ACQ.TRADE_HAS_SUCCESS

sub_msg

String

Description of the processing result of the request

Example:Payment for the transaction is completed.

sign

String Required

The signature value. See Signature for details.

Example:DZXh8eeTuAHoYE3w1J+POiPhfDxOYBfUNn1lkeT/V7P4zJdyojWEa6IZs6Hz0yDW5Cp/viufUb5I0/V5WENS3OYR8zRedqo6D+fUTdLHdc+EFyCkiQhBxIzgngPdPdfp1PIS7BdhhzrsZHbRqb7o4k3Dxc+AAnFauu4V6Zdwczo=

Business parameter

image_id

String (32) Required

The unique ID assigned by Alipay to identify an image or video

Example:hOTQ1lT1TtOjcxGflvnUXgAAACMAAQED

image_url

String (512) Required

URL of the image or video
Example:http://dl.django.t.taobao.com/rest/1.0/image?fileIds=V9rfg69SSimLZg5wDA3yEgAAACMA...

Business error code

Error code

Description

Solution

INVALID_PARAM

The request parameters are invalid.

Use correct parameters in the request

SYSTEM_ERROR

System error

Try again later.

EXCEED_MAX_SIZE

Image size exceeds 5 MB, or video size exceeds 50 MB.

Reduce the file size and retry.

UNKNOWN_FORMAT

The file format is not supported.

Use only BMP, PNG, JPEG, JPG, and GIF for images. Use only MP4 for videos.

INVALID_FILE_BYTES

The binary data is not that of an image or video file.

Ensure the binary data is of an image or video file of the supported formats.

CAPACITY_EXCEEDED

A merchant cannot upload more than 5000 images/videos.

Delete the unnecessary images or videos and retry.

Sample

Request sample

JAVA

copy
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do","app_id","your private_key","json","GBK","alipay_public_key","RSA2");
AlipayOfflineMaterialImageUploadRequest request = new AlipayOfflineMaterialImageUploadRequest();
request.setImageType("jpg or mp4");
request.setImageName("Jack");
FileItem ImageContent = new FileItem(C:/Downloads/ooopic_963991_7eea1f5426105f9e6069/16365_1271139700.jpg);
request.setImageContent(ImageContent);
request.setImagePid("2088021822217233");
AlipayOfflineMaterialImageUploadResponse response = alipayClient.execute(request);
if(response.isSuccess()){
System.out.println("Call succeeds");
} else {
System.out.println("Call fails");
}
       

.NET

copy
IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", "app_id", "merchant_private_key", "json", "1.0", "RSA2", "alipay_public_key", "GBK", false);
AlipayOfflineMaterialImageUploadRequest  request= new AlipayOfflineMaterialImageUploadRequest() ;
request.ImageType = "jpg or mp4";
request.ImageName = "Jack";
FileItem ImageContent = new FileItem(C:/Downloads/ooopic_963991_7eea1f5426105f9e6069/16365_1271139700.jpg);
request.setImageContent = "-";
request.ImagePid = "2088021822217233";
AlipayOfflineMaterialImageUploadResponse response=client.Execute(request);
Console.WriteLine(response.Body);

PHP

copy
$aop = new AopClient ();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = 'your app_id';
$aop->rsaPrivateKey = 'Please fill in the developer's private key in a line of string, removing the head, tail, and carriage return';
$aop->alipayrsaPublicKey='Please fill in Alipay public key in a line of string';
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='GBK';
$aop->format='json';
$request = new AlipayOfflineMaterialImageUploadRequest ();
$request->setImageType("jpg or mp4");
$request->setImageName("Jack");
$request->setImageContent("@"."Local file path");
$request->setImagePid("2088021822217233");
$result = $aop->execute ( $request); 

 

HTTP request source code

copy
https://openapi.alipay.com/gateway.do?timestamp=2013-01-01 08:08:08&method=alipay.offline.material.image.upload&app_id=2361&sign_type=RSA2&sign=ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE&version=1.0&image_type=
  "jpg or mp4"
&image_name=
  "Jack"
&image_pid=
  "2088021822217233"

//To ensure a secure communication, verify whether the sign value in the response sample is provided by Ant Financial.

Response sample

JSON

copy
{
    "alipay_offline_material_image_upload_response": {
        "code": "10000",
        "msg": "Success",
        "image_id": "hOTQ1lT1TtOjcxGflvnUXgAAACMAAQED",
        "image_url": "http://dl.django.t.taobao.com/rest/1.0/image?fileIds=V9rfg69SSimLZg5wDA3yEgAAACMA..."
    },
    "sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
}
       

XML

copy
<alipay_offline_material_image_upload_response>
<code>10000</code>
<msg>Success</msg>  <image_id>hOTQ1lT1TtOjcxGflvnUXgAAACMAAQED</image_id>
  <image_url>http://dl.django.t.taobao.com/rest/1.0/image?fileIds=V9rfg69SSimLZg5wDA3yEgAAACMA...</image_url>
</alipay_offline_material_image_upload_response>

Exception sample

JSON

copy
{
    "alipay_offline_material_image_upload_response": {
        "code": "20000",
        "msg": "Service Currently Unavailable",
        "sub_code": "isp.unknow-error",
        "sub_msg": "System busy"
    },
    "sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
}