Add temporary assets


Add temporary material

1474938506730644.png

Public accounts often have scenes that require the use of some temporary multimedia materials, such as When using the interface, especially when sending messages, operations such as obtaining and calling multimedia files and multimedia messages are performed through media_id. The material management interface is open to all certified subscription accounts and service accounts. Through this interface, public accounts can add temporary materials (i.e. upload temporary multimedia files).

Please note:

#1. For temporary materials, each The material (media_id) will be automatically deleted 3 days after the developer uploads it or the fan sends it to the WeChat server (so the material sent by the user to the developer should be downloaded locally as soon as possible if the developer needs it) to save server resources.

2. media_id is reusable.

3. The format and size requirements of the materials are consistent with the official website of the public platform. Specifically, the image size does not exceed 2M, supports png/jpeg/jpg/gif format, the voice size does not exceed 5M, the length does not exceed 60 seconds, and supports mp3/amr format

##4, You need to use https to call this interface.

This interface is the original "upload multimedia file" interface.

Interface call request description

http request method: POST/FORM, need to use https

https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE

Calling example (use curl command, use FORM Upload a multimedia file via form):
curl -F media=@test.jpg "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE"

Parameter Description

Return instructions

The returned JSON data packet result under correct conditions is as follows:

{ "type":"TYPE","media_id":"MEDIA_ID","created_at":123456789}
ParameterIs it requiredDescription
access_token is the calling interface credential
##type

is

Media file types include image, voice, video and thumbnail
media is the media file identifier in form-data, including filename, filelength, content-type and other information
ParametersDescription
typeMedia file types include image, voice, video and thumbnail (mainly used for thumbnails in video and music formats)
media_idThe unique identification when obtaining the media file after it is uploaded
created_atMedia file upload timestamp

An example of the returned JSON data packet in error conditions is as follows (the example is an invalid media type error):

{"errcode":40004,"errmsg":"invalid media type "}

##Notes

The uploaded temporary multimedia files have format and size restrictions, as follows:

Image: 2M, supports PNG\JPEG\JPG\GIF format

Voice: 2M, playback length does not exceed 60s, supports AMR\ MP3 format

Video: 10MB, supports MP4 format

Thumbnail: 64KB, supports JPG format

Media files are saved in the background for 3 days, that is, the media_id will expire after 3 days.

Use web debugging tools to debug this interface