소스 검색

#165 MediaDownloadRequestExecutor出错后就没有办法下载了

master
Daniel Qian 10 년 전
부모
커밋
4bee1ba2eb
1개의 변경된 파일16개의 추가작업 그리고 9개의 파일을 삭제
  1. +16
    -9
      weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java

+ 16
- 9
weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java 파일 보기

@@ -63,16 +63,23 @@ public class MediaDownloadRequestExecutor implements RequestExecutor<File, Strin
throw new WxErrorException(WxError.fromJson(responseContent));
}
}
InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response);
// 视频文件不支持下载
String fileName = getFileName(response);
if (StringUtils.isBlank(fileName)) {
return null;
InputStream inputStream = null;
try {
inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response);

// 视频文件不支持下载
String fileName = getFileName(response);
if (StringUtils.isBlank(fileName)) {
return null;
}
String[] name_ext = fileName.split("\\.");
File localFile = FileUtils.createTmpFile(inputStream, name_ext[0], name_ext[1], tmpDirFile);
return localFile;
} finally {
if (inputStream != null) {
inputStream.close();
}
}
String[] name_ext = fileName.split("\\.");
File localFile = FileUtils.createTmpFile(inputStream, name_ext[0], name_ext[1], tmpDirFile);
return localFile;
}

protected String getFileName(CloseableHttpResponse response) {


불러오는 중...
취소
저장