fix: resolve file extension validation failure issue in editor uploads (#7275)

#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

将获取文件名的代码由 `Part.name()` 改为 `FilePart.filename()`。`Part.name()` 在没有覆写 form 时可能无法正确获取到文件的客户端路径。

#### How to test it?

1. 在文章设置 - 附件存储策略 中,设置一个其他的附件存储策略。
2. 测试在富文本编辑器中上传文件是否报错文件类型与后缀不匹配的问题。

#### Which issue(s) this PR fixes:

Fixes #7274 

#### Does this PR introduce a user-facing change?
```release-note
解决在默认编辑器中上传文件失败的问题
```
pull/7278/head
Takagi 2025-03-07 15:54:59 +08:00 committed by GitHub
parent 577dc1ce06
commit eeb707bd9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -159,8 +159,8 @@ class LocalAttachmentUploadHandler implements AttachmentHandler {
var typeValidator = file.content()
.next()
.handle((dataBuffer, sink) -> {
var mimeType = detectMimeType(dataBuffer.asInputStream(), file.name());
if (!FileTypeDetectUtils.isValidExtensionForMime(mimeType, file.name())) {
var mimeType = detectMimeType(dataBuffer.asInputStream(), file.filename());
if (!FileTypeDetectUtils.isValidExtensionForMime(mimeType, file.filename())) {
handleFileTypeError(sink, "fileTypeNotMatch", mimeType);
return;
}