/**
* 视频上传
*
* @param filePath 文件路径
* @param accessToken accessToken
* @return
* @throws IOException
*/
j.put("title", title);
j.put("introduction", introduction);
String action = "http://api.weixin.qq.com/cgi-bin/material/add_material?access_token=" + accessToken;
URL urlFile = new URL(action);
String result = null;
if (!file.exists() || !file.isFile()) {
throw new IOException("上传的视频不存在");
}
long filelength = file.length();
String fileName=file.getName();
// String suffix=fileName.substring(fileName.lastIndexOf("."),fileName.length());
String type="video/mp4"; //我这里写死
* 视频上传
*
* @param filePath 文件路径
* @param accessToken accessToken
* @return
* @throws IOException
*/
public String upVideo(String filePath, String accessToken, String title, String introduction) throws IOException {
File file = new File(filePath);
JSONObject j = new JSONObject();j.put("title", title);
j.put("introduction", introduction);
String action = "http://api.weixin.qq.com/cgi-bin/material/add_material?access_token=" + accessToken;
URL urlFile = new URL(action);
String result = null;
if (!file.exists() || !file.isFile()) {
throw new IOException("上传的视频不存在");
}
long filelength = file.length();
String fileName=file.getName();
// String suffix=fileName.substring(fileName.lastIndexOf("."),fileName.length());
String type="video/mp4"; //我这里写死