feat(storage): 统一二进制对象存储与公开错误
新增 Aliyun OSS 与 S3 协议、通道内重试和按优先级跨通道切换,保留 server-main 兼容与环境 OSS 内存通道。 将请求及结果中的 Base64、Data URI、Buffer、multipart 和内联二进制统一对象化,生产路径不再写入本机静态目录,历史本地资源仅保留只读兼容。 引入 PublicErrorV1 并统一 API、异步查询、兼容协议和失败回调的安全错误输出,同时补充迁移、管理端、指标、OpenAPI 与本地模拟验收。 验证:go test ./... -count=1;go vet ./...;pnpm lint;pnpm test;pnpm build;pnpm openapi;tests/ci/migrations-test.sh。
This commit is contained in:
@@ -41,6 +41,33 @@ func TestRequestAssetFromValueDetectsDataURLAndRawBase64(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequestAssetFromBinaryValueDetectsBufferAndByteArray(t *testing.T) {
|
||||
png := []any{float64(0x89), float64('P'), float64('N'), float64('G')}
|
||||
decoded, ok, err := requestAssetFromBinaryValue("image", []string{"input", "image"}, map[string]any{
|
||||
"type": "Buffer",
|
||||
"data": png,
|
||||
"mimeType": "image/png",
|
||||
}, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !ok || decoded.ContentType != "image/png" || len(decoded.Bytes) != 4 || decoded.Bytes[0] != 0x89 {
|
||||
t.Fatalf("unexpected Buffer asset: ok=%v decoded=%+v", ok, decoded)
|
||||
}
|
||||
|
||||
decoded, ok, err = requestAssetFromBinaryValue("bytes", []string{"input_audio", "bytes"}, png, map[string]any{"format": "mp3"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !ok || len(decoded.Bytes) != 4 {
|
||||
t.Fatalf("unexpected byte array asset: ok=%v decoded=%+v", ok, decoded)
|
||||
}
|
||||
|
||||
if _, ok, err := requestAssetFromBinaryValue("values", []string{"embedding", "values"}, png, nil); err != nil || ok {
|
||||
t.Fatalf("ordinary numeric arrays must remain JSON: ok=%v err=%v", ok, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMediaRequestBodySlotLimitsPreAuthWorkAndCanReleaseEarly(t *testing.T) {
|
||||
server := &Server{mediaRequestBodySlots: make(chan struct{}, 2)}
|
||||
var critical atomic.Int64
|
||||
|
||||
Reference in New Issue
Block a user