fix(infra): support configuring the HTTP schema of storage upload in … (#450)

This commit is contained in:
junwen-lee
2025-08-01 12:16:57 +08:00
committed by GitHub
parent 6f305e33aa
commit 568819b8e5
6 changed files with 17 additions and 11 deletions

View File

@@ -22,6 +22,8 @@ import (
"fmt"
"io"
"net/http"
"os"
"strings"
"time"
"github.com/volcengine/ve-tos-golang-sdk/v2/tos"
@@ -31,11 +33,9 @@ import (
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
"github.com/coze-dev/coze-studio/backend/infra/impl/storage/proxy"
"github.com/coze-dev/coze-studio/backend/pkg/ctxcache"
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
"github.com/coze-dev/coze-studio/backend/pkg/logs"
"github.com/coze-dev/coze-studio/backend/types/consts"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
type tosClient struct {
@@ -232,9 +232,9 @@ func (t *tosClient) GetServerID() string {
}
func (t *tosClient) GetUploadAuth(ctx context.Context, opt ...imagex.UploadAuthOpt) (*imagex.SecurityToken, error) {
scheme, ok := ctxcache.Get[string](ctx, consts.RequestSchemeKeyInCtx)
if !ok {
return nil, errorx.New(errno.ErrUploadHostSchemaNotExistCode)
scheme := strings.ToLower(os.Getenv(consts.StorageUploadHTTPScheme))
if scheme == "" {
scheme = "http"
}
return &imagex.SecurityToken{
AccessKeyID: "",