当前位置:网站首页>Wechat official account development: Material Management (temporary and permanent)
Wechat official account development: Material Management (temporary and permanent)
2022-07-24 12:06:00 【Don't wear perfume】
List of articles
explain
This article is for reference only , But make sure the code is available
Please check first Official website material management
1、 Description of the material on the official website 
2. Upload the description of the interface 
Actually measured Temporary material interface File parameter name in media You can use non fixed parameter names , Change to as file Parameter names like can still be uploaded successfully
3.access_token
Reference resources : Wechat official account news push development ( Template message ): The development of implementation ( Two )
Code implementation
1. The code shown below is not an interface , You can modify 2. Yes voice When judging the type of file , Time length is not checked , Please make your own judgment 3. The following pictures are used as demonstration materials 4 Use httpclient Simulation of the request
Introduce dependencies
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5</version>
</dependency>
1. Add temporary material
https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type=TYPE
1. establish mediaUpload.java
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
/** * @author lvyq * @version 1.0 * @description: Upload files * @date 2022/7/14 10:04 */
public class mediaUpload {
private static Logger logger = LoggerFactory.getLogger(mediaUpload.class);
public static final String ACCESS_TOKEN="xxxxxxxx";
public static void main(String[] args) throws Exception{
// Local multimedia file address
String file ="D:\\ picture .jpeg";
curlFileUpload(file,"image");
}
/** * @description: simulation curl Upload local file * @author: lvyq * @date: 2022/7/14 10:05 * @version 1.0 */
public static void curlFileUpload(String filePath,String type) throws Exception{
String mediaUploadUrl = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE";
CloseableHttpClient httpClient = HttpClients.createDefault();
String result = "";
try {
File media = new File(filePath);
mediaUploadUrl =replaceURLByFile(media,type,mediaUploadUrl);
if (mediaUploadUrl!=null){
HttpPost httpPost = new HttpPost(mediaUploadUrl);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
// Upload multimedia files
builder.addBinaryBody("media", media);
HttpEntity entity = builder.build();
httpPost.setEntity(entity);
// Execute commit
HttpResponse response = httpClient.execute(httpPost);
HttpEntity responseEntity = response.getEntity();
if (responseEntity != null) {
result = EntityUtils.toString(responseEntity, Charset.forName("UTF-8"));
}
}else {
logger.error(" Upload failed ");
}
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
logger.info(" The request is successful :"+result);
}
/** * @description: Verify file type * @author: lvyq * @date: 2022/7/14 10:29 * @version 1.0 */
private static String replaceURLByFile(File media,String type,String mediaUploadUrl) {
if (media.isFile()){
//image check
if (type.equals("image")){
if (!checkFileType(type,getFileSuffix(media))|| getFileSize(media)>10*1024*1024){
logger.error(" File type does not support , Or the file is larger than 10M");
return null;
}
}else if (type.equals("voice")){
if (!checkFileType(type,getFileSuffix(media)) || getFileSize(media)>2*1024*1024){
logger.error(" File type does not support , Or the file is larger than 2M");
return null;
}
}else if (type.equals("video")){
if (!"MP4".equalsIgnoreCase(getFileSuffix(media)) || getFileSize(media)>2*1024*1024){
logger.error(" File type does not support , Or the file is larger than 2M");
return null;
}
}else if (type.equals("thumb")){
if (!"JPG".equalsIgnoreCase(getFileSuffix(media)) || getFileSize(media)>64*1024){
logger.error(" File type does not support , Or the file is larger than 64KB");
return null;
}
}else {
logger.error(" File does not support ");
return null;
}
}else {
logger.error(" file does not exist ");
return null;
}
mediaUploadUrl=mediaUploadUrl.replace("ACCESS_TOKEN",ACCESS_TOKEN).replace("TYPE",type);
return mediaUploadUrl;
}
/** * Get file suffix * * @param file * @return */
public static String getFileSuffix(File file) {
String suffix="";
String fileName = file.getName();
if (fileName.lastIndexOf(".") != -1 && fileName.lastIndexOf(".") != 0) {
suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
}
return suffix;
}
/** * @description: Determine file type * @author: lvyq * @date: 2022/7/15 17:22 * @version 1.0 */
public static boolean checkFileType(String type,String mediaType){
boolean ble = false;
if (type.equals("image")){
if (mediaType.equalsIgnoreCase("PNG") || mediaType.equalsIgnoreCase("JPEG") || mediaType.equalsIgnoreCase("JPG") || mediaType.equalsIgnoreCase("GIF")){
ble=true;
}
}else if(mediaType.equalsIgnoreCase("AMR") || mediaType.equalsIgnoreCase("MP3") ){
ble=true;
}
return ble;
}
/** * @description: Get file size * @author: lvyq * @date: 2022/7/15 16:09 * @version 1.0 */
public static long getFileSize(File file) {
if (!file.exists() || !file.isFile()) {
logger.error(" file does not exist ");
return -1;
}
logger.info("length:{}",file.length());
return file.length();
}
}
Execution results :
13:09:59.100 [main] INFO mediaUpload - The request is successful :{“type”:“image”,“media_id”:“Dw0HCQJSkt02hWlEY-NC5DRN-kSbmqOVU5ZnjpwEFlmY2jbx9uB4oxATZCdxjwk3”,“created_at”:1657948199,“item”:[]}
The temporary file is uploaded successfully and returned media_id
2. Get temporary material
After the temporary material is obtained, it is a file stream , If it is played directly in the browser, it will be downloaded directly to the local
https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID
take Add temporary material Example modification
Use the above media_id
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.Charset;
/** * @author lvyq * @version 1.0 * @description: Upload files * @date 2022/7/14 10:04 */
public class mediaUpload {
private static Logger logger = LoggerFactory.getLogger(mediaUpload.class);
public static final String ACCESS_TOKEN="xxxxx";
public static void main(String[] args) throws Exception{
httpGet(ACCESS_TOKEN,"Dw0HCQJSkt02hWlEY-NC5DRN-kSbmqOVU5ZnjpwEFlmY2jbx9uB4oxATZCdxjwk3");
}
/** * @description: Get temporary material * @author: lvyq * @date: 2022/7/14 10:05 * @version 1.0 */
public static void httpGet(String ACCESS_TOKEN,String MEDIA_ID) throws Exception{
String url="https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID";
url=url.replace("ACCESS_TOKEN",ACCESS_TOKEN).replace("MEDIA_ID",MEDIA_ID);
CloseableHttpClient httpClient = HttpClients.createDefault();
String result = "";
HttpGet httpGet = new HttpGet(url);
// Execute commit
HttpResponse response = httpClient.execute(httpGet);
HttpEntity responseEntity = response.getEntity();
if (responseEntity != null) {
result = EntityUtils.toString(responseEntity, Charset.forName("UTF-8"));
}
logger.info(" The request is successful :"+result);
}
Perform rear console output

It can be seen that the output is a file stream , If it is used for front-end echo , Need to transform , If you access it directly in the browser , Will download directly , The official website also gives instructions 
Browser access effect 
3. Add permanent material
The main difference with temporary materials :
1. Know what you know , There is no such thing as expiration , Will not automatically delete
2. The supported material formats are also different , See the official website for details There are two interfaces for uploading permanent materials , You can choose according to your own needs , The following is a brief demonstration based on two interfaces
1. Image acquisition in uploaded text message URL
The benefits of using have been officially explained :
People don't talk too much
https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN
take Add temporary material Example modification
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.Charset;
/** * @author lvyq * @version 1.0 * @description: Upload files * @date 2022/7/14 10:04 */
public class mediaUpload {
private static Logger logger = LoggerFactory.getLogger(mediaUpload.class);
public static final String ACCESS_TOKEN="xxxxxx";
public static void main(String[] args) throws Exception{
// Local multimedia file address
String file ="D:\\ picture .jpeg";
curlFileUpload(file);
}
/** * @description: simulation curl Upload local file * @author: lvyq * @date: 2022/7/14 10:05 * @version 1.0 */
public static void curlFileUpload(String filePath) throws Exception{
// Image acquisition in uploaded text message URL
String mediaUploadUrl = "https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN";
mediaUploadUrl=mediaUploadUrl.replace("ACCESS_TOKEN",ACCESS_TOKEN);
CloseableHttpClient httpClient = HttpClients.createDefault();
String result = "";
try {
File media = new File(filePath);
if (mediaUploadUrl!=null){
HttpPost httpPost = new HttpPost(mediaUploadUrl);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
// Upload multimedia files
builder.addBinaryBody("media", media);
HttpEntity entity = builder.build();
httpPost.setEntity(entity);
// Execute commit
HttpResponse response = httpClient.execute(httpPost);
HttpEntity responseEntity = response.getEntity();
if (responseEntity != null) {
result = EntityUtils.toString(responseEntity, Charset.forName("UTF-8"));
}
}else {
logger.error(" Upload failed ");
}
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
logger.info(" The request is successful :"+result);
}
}
Check the console after execution 
Returned a url Check the material library , It is not found that the uploaded file is in the material library 
2. Add other types of permanent materials
1. The process is the same as that of uploading new temporary materials , The material format is slightly different from that of temporary material 2. When uploading video material in this example , Please modify according to the official requirements , Just pass the corresponding parameters 
No more beeps
https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type=TYPE
take Add temporary material Example modification
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.Charset;
/** * @author lvyq * @version 1.0 * @description: Upload files * @date 2022/7/14 10:04 */
public class mediaUpload {
private static Logger logger = LoggerFactory.getLogger(mediaUpload.class);
public static final String ACCESS_TOKEN="xxxxxxxx";
public static void main(String[] args) throws Exception{
// Local multimedia file address
String file ="D:\\ picture .jpeg";
curlFileUpload(file,"image");
}
/** * @description: simulation curl Upload local file * @author: lvyq * @date: 2022/7/14 10:05 * @version 1.0 */
public static void curlFileUpload(String filePath,String type) throws Exception{
String mediaUploadUrl="https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type=TYPE";
CloseableHttpClient httpClient = HttpClients.createDefault();
String result = "";
try {
File media = new File(filePath);
mediaUploadUrl =replaceURLByFile(media,type,mediaUploadUrl);
if (mediaUploadUrl!=null){
HttpPost httpPost = new HttpPost(mediaUploadUrl);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
// Chinese upload garbled
//builder.setMode(HttpMultipartMode.RFC6532);
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
// Upload multimedia files
builder.addBinaryBody("media", media);
HttpEntity entity = builder.build();
httpPost.setEntity(entity);
// Execute commit
HttpResponse response = httpClient.execute(httpPost);
HttpEntity responseEntity = response.getEntity();
if (responseEntity != null) {
result = EntityUtils.toString(responseEntity, Charset.forName("UTF-8"));
}
}else {
logger.error(" Upload failed ");
}
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
logger.info(" The request is successful :"+result);
}
// Other methods are omitted , Pass reference to new temporary materials
}
perform
15:04:55.028 [main] INFO mediaUpload - The request is successful :{“media_id”:“oGIlgGzH9Nn056liMjQKx4DVWQcNRDuJrHU4rrxqED0X7OjOdgRzty7LvgzHvaHb”,“url”:“http://mmbiz.qpic.cn/mmbiz_jpg/VaIMNgZtU3TG3icibjYYuHc0hErPSp9yukmODO2mNMFsGSfwWMJib99tXmy3aD4tcfIOuTCCTiaMiciaCaPicDw99n8Gw/0?wx_fmt=jpeg”,“item”:[]}
return media_id and url, Check the material library 
It is found that the uploaded file name is garbled , Don't panic
Use builder.setMode(HttpMultipartMode.RFC6532)
Upload and view again 
Please verify by yourself !!!
4. Get permanent material
Official website 
Get different types of materials , The content returned is also different , Please check the official website
https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=ACCESS_TOKEN
take Add temporary material Example modification
package com.lvyq.utils.me;
import com.alibaba.fastjson.JSONObject;
import com.tencentcloudapi.mna.v20210119.models.SrcAddressInfo;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.*;
import java.io.*;
import java.net.ConnectException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
/** * @author lvyq * @version 1.0 * @description: Upload files * @date 2022/7/14 10:04 */
public class mediaUpload {
private static Logger logger = LoggerFactory.getLogger(mediaUpload.class);
public static final String ACCESS_TOKEN="xxxxx";
public static void main(String[] args) throws Exception{
String MEDIA_ID="oGIlgGzH9Nn056liMjQKx4DVWQcNRDuJrHU4rrxqED0X7OjOdgRzty7LvgzHvaHb";
String mediaUploadUrl="https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=ACCESS_TOKEN";
mediaUploadUrl= mediaUploadUrl.replace("ACCESS_TOKEN",ACCESS_TOKEN);
JSONObject mav = new JSONObject();
mav.put("media_id",MEDIA_ID);
sendPost(mediaUploadUrl,mav.toJSONString());
}
public static void sendPost(String url, String param) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
URLConnection conn = realUrl.openConnection();
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.setDoOutput(true);
conn.setDoInput(true);
out = new PrintWriter(new OutputStreamWriter(conn.getOutputStream(), "UTF-8"));
out.print(param);
out.flush();
String line;
for(in = new BufferedReader(new InputStreamReader(conn.getInputStream())); (line = in.readLine()) != null; result = result + line) {
}
} catch (Exception var16) {
System.out.println(" send out POST Exception in request !" + var16);
var16.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException var15) {
var15.printStackTrace();
}
}
logger.info("result:{}"+result);
}
}
Check that a stream is returned 
Reaffirm !!! This article takes pictures as an example to demonstrate , Different materials , The data returned is also different
5. Delete permanent material
https://api.weixin.qq.com/cgi-bin/material/del_material?access_token=ACCESS_TOKEN
take Get permanent material Just change it , I won't post the code , Replace url Just go
Running results 
Check the material library 
Deleted successfully !!!
6. Total number of materials obtained
Website shows 
GET https://api.weixin.qq.com/cgi-bin/material/get_materialcount?access_token=ACCESS_TOKEN
take Get temporary material Example modification
package com.lvyq.utils.me;
import com.alibaba.fastjson.JSONObject;
import com.tencentcloudapi.mna.v20210119.models.SrcAddressInfo;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.*;
import java.io.*;
import java.net.ConnectException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
/** * @author lvyq * @version 1.0 * @description: Upload files * @date 2022/7/14 10:04 */
public class mediaUpload {
private static Logger logger = LoggerFactory.getLogger(mediaUpload.class);
public static final String ACCESS_TOKEN="xxxxx";
public static void main(String[] args) throws Exception{
httpGet();
}
public static void httpGet() throws Exception{
String url="https://api.weixin.qq.com/cgi-bin/material/get_materialcount?access_token=ACCESS_TOKEN";
url=url.replace("ACCESS_TOKEN",ACCESS_TOKEN);
CloseableHttpClient httpClient = HttpClients.createDefault();
String result = "";
HttpGet httpGet = new HttpGet(url);
// Execute commit
HttpResponse response = httpClient.execute(httpGet);
HttpEntity responseEntity = response.getEntity();
if (responseEntity != null) {
result = EntityUtils.toString(responseEntity, Charset.forName("UTF-8"));
}
logger.info(" The request is successful :"+result);
}
Execution results
16:27:12.020 [main] INFO com.lvyq.utils.me.mediaUpload - The request is successful :{“voice_count”:0,“video_count”:0,“image_count”:2,“news_count”:0}
7. Get material list
Website shows 
POST https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=ACCESS_TOKEN
take Get permanent material Example modification
package com.lvyq.utils.me;
import com.alibaba.fastjson.JSONObject;
import com.tencentcloudapi.mna.v20210119.models.SrcAddressInfo;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.*;
import java.io.*;
import java.net.ConnectException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
/** * @author lvyq * @version 1.0 * @description: Upload files * @date 2022/7/14 10:04 */
public class mediaUpload {
private static Logger logger = LoggerFactory.getLogger(mediaUpload.class);
public static final String ACCESS_TOKEN="xxxxxx";
public static void main(String[] args) throws Exception{
String mediaUploadUrl="https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=ACCESS_TOKEN";
mediaUploadUrl= mediaUploadUrl.replace("ACCESS_TOKEN",ACCESS_TOKEN);
JSONObject mav = new JSONObject();
mav.put("type","image");
mav.put("offset",0);
mav.put("count",20);
sendPost(mediaUploadUrl,mav.toJSONString());
}
public static void sendPost(String url, String param) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
URLConnection conn = realUrl.openConnection();
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.setDoOutput(true);
conn.setDoInput(true);
out = new PrintWriter(new OutputStreamWriter(conn.getOutputStream(), "UTF-8"));
out.print(param);
out.flush();
String line;
for(in = new BufferedReader(new InputStreamReader(conn.getInputStream())); (line = in.readLine()) != null; result = result + line) {
}
} catch (Exception var16) {
System.out.println(" send out POST Exception in request !" + var16);
var16.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException var15) {
var15.printStackTrace();
}
}
logger.info("result:{}"+result);
}
}
Execution results
16:35:22.614 [main] INFO com.lvyq.utils.me.mediaUpload - result:{}{“item”:[{“media_id”:“oGIlgGzH9Nn056liMjQKx9MKdOreL8nSh9Ye-8n2qfy5z6qfsHYZHCnsFhJcE8VV”,“name”:“ picture .jpeg”,“update_time”:1657955287,“url”:“https://mmbiz.qpic.cn/mmbiz_jpg/VaIMNgZtU3TG3icibjYYuHc0hErPSp9yukmODO2mNMFsGSfwWMJib99tXmy3aD4tcfIOuTCCTiaMiciaCaPicDw99n8Gw/0?wx_fmt=jpeg”,“tags”:[]},{“media_id”:“oGIlgGzH9Nn056liMjQKx0d_JL18mla2TPK_W8J15ThlUzGdFqEEql-Xc_ZEWNSV”,“name”:“ Wechat screenshot _20220528144310.png”,“update_time”:1653720213,“url”:“https://mmbiz.qpic.cn/mmbiz_png/VaIMNgZtU3SsC1oQmm0M21oLia8C8LXZEP5Ggg5kekgErkAy6knR9h7Kou9aM8ATTt88ibjw5dtQY5ev9oiaibRf2w/0?wx_fmt=png”,“tags”:[]}],“total_count”:2,“item_count”:2}
Other :
1. This article takes local files as an example to demonstrate , In actual development, the interface needs to be changed to be used by the front end 2. In actual development , General reception MultipartFile file type , When used, will MultipartFile To File that will do
边栏推荐
- Hash - 349. Intersection of two arrays
- 计算两个坐标经纬度之间的距离(5种方式)
- 安装jmeter
- Shell Scripting tips
- String -- 344. Reverse string
- Delphi gexperts expert instructions for improving development efficiency
- CCF 1-2 question answering record (2)
- [mathematical basis of Cyberspace Security Chapter 9] finite field
- [data mining engineer - written examination] sheen company in 2022
- AcWing 92. 递归实现指数型枚举
猜你喜欢

微信公众号开发:素材管理(临时、永久)

Recommended SSH cross platform terminal tool tabby
![Operational amplifier - Notes on rapid recovery [1] (parameters)](/img/1f/37c5548ce84b6a217b4742431f1cc4.png)
Operational amplifier - Notes on rapid recovery [1] (parameters)

4*4图片权重的收敛规则

Use prometheus+grafana to monitor server performance in real time

Source code analysis sentry user behavior record implementation process

2 万字详解,吃透 ES!

L1-059 敲笨钟

QT notes - qtablewidget table spanning tree, qtreewidget tree node generates table content

1184. 公交站间的距离 : 简单模拟题
随机推荐
C#入门系列(二十九) -- 预处理命令
Use of multithreading in QT
Day5: construct program logic
Jackson parsing JSON detailed tutorial
Optimization method of "great mathematics for use" -- optimal design of Cascade Reservoir Irrigation
一周精彩内容分享(第13期)
js图像转base64
动态内存管理
VMware virtual machine and vSphere migrate to each other
Hash - 1. Sum of two numbers - some people fall in love during the day, some people watch the sea at night, and some people can't do the first question
Repeated calls, messages, idempotent schemes, full collation
How to eliminate the character set and sorting rules specially set for fields in MySQL tables?
CCF 201803_ 1 jump jump
Threat hunting collection
Top and bottom of stack
A*与JPS
3、 Implementation principle of MFC message mapping mechanism
生信周刊第37期
In kuborad graphical interface, operate kubernetes cluster to realize master-slave replication in MySQL
MySQL advanced (XVII) cannot connect to database server problem analysis