mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-23 22:11:40 +08:00
#471 上传多媒体文件时临时文件及时清理,防止本地产生过多系统垃圾
This commit is contained in:
parent
070ff05fdf
commit
a11de1977c
@ -34,10 +34,16 @@ public class WxMpMaterialServiceImpl implements WxMpMaterialService {
|
||||
|
||||
@Override
|
||||
public WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException {
|
||||
File tmpFile = null;
|
||||
try {
|
||||
return this.mediaUpload(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType));
|
||||
tmpFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType);
|
||||
return this.mediaUpload(mediaType, tmpFile);
|
||||
} catch (IOException e) {
|
||||
throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg(e.getMessage()).build(), e);
|
||||
} finally {
|
||||
if (tmpFile != null) {
|
||||
tmpFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user