change code

This commit is contained in:
Looly
2021-11-26 20:38:13 +08:00
parent 449e748f62
commit c85f204da9
2 changed files with 6 additions and 3 deletions

View File

@@ -7,7 +7,6 @@ import cn.hutool.core.io.IORuntimeException;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.io.StreamProgress;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
@@ -434,7 +433,10 @@ public class HttpResponse extends HttpBase<HttpResponse> implements Closeable {
fileName = StrUtil.subSuf(path, path.lastIndexOf('/') + 1);
if (StrUtil.isBlank(fileName)) {
// 编码后的路径做为文件名
fileName = URLUtil.encodeQuery(path, CharsetUtil.CHARSET_UTF_8);
fileName = URLUtil.encodeQuery(path, charset);
} else {
// issue#I4K0FS@Gitee
fileName = URLUtil.decode(fileName, charset);
}
}
return FileUtil.file(targetFileOrDir, fileName);