Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce? (check at least one)
The description of the PR:
1.文件名处理增强:
提取 URL 中最后一段作为基础文件名,避免使用完整 URL 导致文件名过长
完善非法字符过滤,覆盖 Windows 和 Linux 系统的特殊字符
处理 contentType 中可能包含的参数(如;charset=utf-8)
限制文件名最大长度,防止超出操作系统限制
2.文件保存优化:
增加参数校验,避免空指针异常
验证目录创建结果,确保目录可用
使用 NIO API 替代传统 File 类操作,更高效
3.下载功能改进:
添加读取超时设置,避免无限等待
使用临时文件下载,完成后原子性移动,避免生成不完整文件
增大缓冲区大小(8192 字节),提高下载效率
完善异常处理和临时文件清理机制
4.工具方法增强:
exists方法使用 NIO API,更高效且支持更多路径类型
增加详细日志输出,便于问题排查
统一异常处理风格,提高代码可维护性
Other information: