mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-24 16:18:51 +08:00
#165 MediaDownloadRequestExecutor出错后就没有办法下载了
This commit is contained in:
parent
f30211ce98
commit
4bee1ba2eb
@ -63,7 +63,9 @@ public class MediaDownloadRequestExecutor implements RequestExecutor<File, Strin
|
|||||||
throw new WxErrorException(WxError.fromJson(responseContent));
|
throw new WxErrorException(WxError.fromJson(responseContent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response);
|
InputStream inputStream = null;
|
||||||
|
try {
|
||||||
|
inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response);
|
||||||
|
|
||||||
// 视频文件不支持下载
|
// 视频文件不支持下载
|
||||||
String fileName = getFileName(response);
|
String fileName = getFileName(response);
|
||||||
@ -73,6 +75,11 @@ public class MediaDownloadRequestExecutor implements RequestExecutor<File, Strin
|
|||||||
String[] name_ext = fileName.split("\\.");
|
String[] name_ext = fileName.split("\\.");
|
||||||
File localFile = FileUtils.createTmpFile(inputStream, name_ext[0], name_ext[1], tmpDirFile);
|
File localFile = FileUtils.createTmpFile(inputStream, name_ext[0], name_ext[1], tmpDirFile);
|
||||||
return localFile;
|
return localFile;
|
||||||
|
} finally {
|
||||||
|
if (inputStream != null) {
|
||||||
|
inputStream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getFileName(CloseableHttpResponse response) {
|
protected String getFileName(CloseableHttpResponse response) {
|
||||||
|
Loading…
Reference in New Issue
Block a user