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:
@@ -2,6 +2,7 @@ package httpapi
|
||||
|
||||
import (
|
||||
"github.com/easyai/easyai-ai-gateway/apps/api/internal/auth"
|
||||
"github.com/easyai/easyai-ai-gateway/apps/api/internal/publicerror"
|
||||
"github.com/easyai/easyai-ai-gateway/apps/api/internal/store"
|
||||
)
|
||||
|
||||
@@ -32,11 +33,19 @@ type ErrorEnvelope struct {
|
||||
}
|
||||
|
||||
type ErrorPayload struct {
|
||||
Message string `json:"message" example:"invalid json body"`
|
||||
Status int `json:"status" example:"400"`
|
||||
Code string `json:"code,omitempty" example:"rate_limit"`
|
||||
Type string `json:"type,omitempty" example:"invalid_request_error"`
|
||||
Param any `json:"param,omitempty"`
|
||||
Message string `json:"message" example:"invalid json body"`
|
||||
Status int `json:"status" example:"400"`
|
||||
Code string `json:"code,omitempty" example:"rate_limit"`
|
||||
Category string `json:"category,omitempty" example:"rate_limit"`
|
||||
HTTPStatus int `json:"httpStatus,omitempty" example:"429"`
|
||||
Retryable bool `json:"retryable" example:"true"`
|
||||
Action string `json:"action,omitempty" example:"retry_after"`
|
||||
Version string `json:"version,omitempty" example:"v1"`
|
||||
RetryAfterSeconds int `json:"retryAfterSeconds,omitempty" example:"2"`
|
||||
RequestID string `json:"requestId,omitempty"`
|
||||
TaskID string `json:"taskId,omitempty"`
|
||||
Type string `json:"type,omitempty" example:"invalid_request_error"`
|
||||
Param any `json:"param,omitempty"`
|
||||
}
|
||||
|
||||
type OpenAIErrorEnvelope struct {
|
||||
@@ -62,12 +71,7 @@ type GeminiErrorStatus struct {
|
||||
}
|
||||
|
||||
type VolcesErrorEnvelope struct {
|
||||
Error VolcesErrorPayload `json:"error"`
|
||||
}
|
||||
|
||||
type VolcesErrorPayload struct {
|
||||
Code string `json:"code" example:"invalid_parameter"`
|
||||
Message string `json:"message" example:"model is required"`
|
||||
Error publicerror.Error `json:"error"`
|
||||
}
|
||||
|
||||
type VolcesContentsGenerationTaskResponse struct {
|
||||
@@ -82,10 +86,11 @@ type VolcesContentsGenerationTaskResponse struct {
|
||||
}
|
||||
|
||||
type KlingErrorEnvelope struct {
|
||||
Code int `json:"code" example:"1001"`
|
||||
Message string `json:"message" example:"invalid parameter"`
|
||||
RequestID string `json:"request_id"`
|
||||
Error string `json:"error,omitempty" example:"invalid_parameter"`
|
||||
Code int `json:"code" example:"1001"`
|
||||
Message string `json:"message" example:"invalid parameter"`
|
||||
RequestID string `json:"request_id"`
|
||||
Error string `json:"error,omitempty" example:"invalid_parameter"`
|
||||
PublicError *publicerror.Error `json:"public_error,omitempty"`
|
||||
}
|
||||
|
||||
type AuthResponse struct {
|
||||
@@ -232,6 +237,14 @@ type FileStorageChannelListResponse struct {
|
||||
Items []store.FileStorageChannel `json:"items"`
|
||||
}
|
||||
|
||||
type FileStorageChannelTestResponse struct {
|
||||
Provider string `json:"provider"`
|
||||
PutSucceeded bool `json:"putSucceeded"`
|
||||
HeadSucceeded bool `json:"headSucceeded"`
|
||||
DeleteSucceeded bool `json:"deleteSucceeded"`
|
||||
DurationMS int64 `json:"durationMs"`
|
||||
}
|
||||
|
||||
type FileUploadResponse struct {
|
||||
ID string `json:"id,omitempty" example:"file_abc123"`
|
||||
URL string `json:"url,omitempty" example:"/static/uploaded/upload-abc123.png"`
|
||||
|
||||
Reference in New Issue
Block a user