feat(attach): 附件可配置限额、流式落盘与分阶段上传
管理端可配类型/体积;上传改流式避免整文件进内存;发帖先选再传并拦截未上传提交;提高 Next proxy 体积上限。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
36
backend/service/attachment_settings_test.go
Normal file
36
backend/service/attachment_settings_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAttachmentExtAllowedLogic(t *testing.T) {
|
||||
// Normalize + default list contains msi/html
|
||||
found := false
|
||||
for _, e := range DefaultAttachmentExts {
|
||||
if e == "msi" {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatal("default list should include msi")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMimeForAttachmentExt(t *testing.T) {
|
||||
if MimeForAttachmentExt(".pdf") == "application/octet-stream" {
|
||||
t.Fatal("pdf should have real mime")
|
||||
}
|
||||
if MimeForAttachmentExt(".html") != "application/octet-stream" {
|
||||
t.Fatal("html should be octet-stream")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileMaxBytesDefault(t *testing.T) {
|
||||
if FileMaxBytes != 20<<20 {
|
||||
t.Fatalf("default FileMaxBytes=%d", FileMaxBytes)
|
||||
}
|
||||
_ = fmt.Sprintf("%d", DefaultAttachmentMaxMB)
|
||||
}
|
||||
Reference in New Issue
Block a user