Skip to content

Commit

Permalink
fix: resolve file extension validation failure issue in editor uploads (
Browse files Browse the repository at this point in the history
#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
解决在默认编辑器中上传文件失败的问题
```
  • Loading branch information
LIlGG authored Mar 7, 2025
1 parent 577dc1c commit eeb707b
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ private Mono<Void> validateFile(FilePart file, PolicySetting setting) {
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;
}
Expand Down

0 comments on commit eeb707b

Please sign in to comment.