# Upload Pictures

# Dxplaination of Interface Call Request

Http request method: POST
https://api.weixin.qq.com/product/img/upload?access_token=xxxxxxxxx&upload_type= 0&resp _type=0&height=108&width=108

# URL Request Parameter Dxplaination

parameter type Is it compulsory? Introductions
upload_type number yes Upload type: 0-binary stream, 1-image url
resp_type number yes Data type: 0-media_id和pay_Media_Id, 1-image link (Product Information Related PicturesBe sure to use this parameter to get a link)
height number no upload_Required when type = 0, height of image, in pixels
width number no upload_Required when type = 0, width of image, in pixels

Image upload size limit

  • resp_type = 0: 2MB
  • resp_type = 1: 10MB

# POST Packet Request Parameter Dxplaination

parameter type Is it compulsory? Introductions
img_url string no upload_Required when type = 1, image url

# Request Example 1

curl -F media=@test.jpg "https://api.weixin.qq.com/product/img/upload?access_token=xxxxxxxxx&upload_type= 0&resp _type=0&height=108&width=108"

# Back-up Example 1

{
    "errcode": 0,
    "errmsg":"ok",
    "pic_file":
    {
        "media_id":   "xlvjalsdhgas",
        "pay_Media_id": "asdgasvdadfa"
    }
}

# Request Example 2

curl -d "{"img_url":"https://xxx.com /yyy"}" "http://api.weixin.qq .com /product/img/upload?access_token=xxxxxxxxx&upload_type = 1&resp _type=1"

# Back-up Example 2

{
    "errcode":0,
    "pic_file":
    {
        "temp_img_url": "xxxxx"
    }
}

# Be careful

  • resp_type=1Time will return like thismmecimage.cn/p/{appid} /{imgKey}A link to a picture, which is permanently valid, and the same picture does not need to be repeatedly uploaded without a repeat call to the interface.
  • The image link returned by the interface has an access frequency limit and is returned when the access frequency is exceeded404Status code. Do not link the image for a user-side (largely visited) presentation.
  • Current access frequency limit rules:
  1. appidDimension: 10000/min。
  2. imgKeyDimensionality: 100/min。
  • Interface to support picture processing zooming/Tailoring/compress/Watermark, etc.), specific methods of use refer to the document: https://cloud.tencent.com/document/product/460/53505 .. within this documentdownload_urlThat is, the image link returned for the current interface

# Dxplaination of callback parameters

parameter type Introductions
Error code number Error code
errmsg string Error message
pic_file.media_id number Media_id
pic_file.pay_Media_id string PaymentMedia_id
temp_img_url string Image temporary url

# Return code

Return code Error Type
-1 System exceptions
-2 Token too long
600201 This link does not require conversion and can be used directly (domain name isstore.mp.video.tencent-cloud.com, or the url prefix ismmbizurl.cn/p/, or the url prefix ismmecimage.cn/p/
101002 The picture size exceeds the limit,resp_type = 0: 2MBresp_type = 1: 10MB