diff --git a/backend/application/base/pluginutil/api.go b/backend/application/base/pluginutil/api.go index fc8fbb22..7555666b 100644 --- a/backend/application/base/pluginutil/api.go +++ b/backend/application/base/pluginutil/api.go @@ -20,9 +20,10 @@ import ( "net/http" "strconv" - "github.com/coze-dev/coze-studio/backend/domain/plugin/entity" "github.com/getkin/kin-openapi/openapi3" + "github.com/coze-dev/coze-studio/backend/domain/plugin/entity" + "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin" common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop_common" "github.com/coze-dev/coze-studio/backend/pkg/errorx" diff --git a/backend/infra/impl/storage/minio/minio.go b/backend/infra/impl/storage/minio/minio.go index a763e5ed..fd852020 100644 --- a/backend/infra/impl/storage/minio/minio.go +++ b/backend/infra/impl/storage/minio/minio.go @@ -24,6 +24,8 @@ import ( "log" "math/rand" "net/url" + "os" + "strings" "time" "github.com/minio/minio-go/v7" @@ -33,9 +35,7 @@ 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/types/consts" - "github.com/coze-dev/coze-studio/backend/types/errno" ) type minioClient struct { @@ -231,9 +231,9 @@ func (m *minioClient) GetServerID() string { } func (m *minioClient) 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: "", diff --git a/backend/infra/impl/storage/tos/tos.go b/backend/infra/impl/storage/tos/tos.go index d236b68e..1b9ecdfd 100644 --- a/backend/infra/impl/storage/tos/tos.go +++ b/backend/infra/impl/storage/tos/tos.go @@ -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: "", diff --git a/backend/types/consts/consts.go b/backend/types/consts/consts.go index 06f5eb54..fd073d4c 100644 --- a/backend/types/consts/consts.go +++ b/backend/types/consts/consts.go @@ -31,6 +31,7 @@ const ( FileUploadComponentType = "FILE_UPLOAD_COMPONENT_TYPE" FileUploadComponentTypeImagex = "imagex" FileUploadComponentTypeStorage = "storage" + StorageUploadHTTPScheme = "STORAGE_UPLOAD_HTTP_SCHEME" StorageType = "STORAGE_TYPE" MinIOAK = "MINIO_AK" diff --git a/docker/.env.debug.example b/docker/.env.debug.example index 15d9b888..e58c0a54 100644 --- a/docker/.env.debug.example +++ b/docker/.env.debug.example @@ -30,6 +30,7 @@ export REDIS_PASSWORD="" # if imagex, you must finish the configuration of export FILE_UPLOAD_COMPONENT_TYPE="storage" + # VolcEngine ImageX export VE_IMAGEX_AK="" export VE_IMAGEX_SK="" @@ -40,6 +41,7 @@ export VE_IMAGEX_UPLOAD_HOST="https://imagex.volcengineapi.com" # Storage component export STORAGE_TYPE="minio" # minio / tos / s3 +export STORAGE_UPLOAD_HTTP_SCHEME="http" # http / https. If coze studio website is https, you must set it to https export STORAGE_BUCKET="opencoze" # MiniIO export MINIO_ROOT_USER=minioadmin diff --git a/docker/.env.example b/docker/.env.example index 772bc743..de116589 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -30,6 +30,7 @@ export REDIS_PASSWORD="" # if imagex, you must finish the configuration of export FILE_UPLOAD_COMPONENT_TYPE="storage" + # VolcEngine ImageX export VE_IMAGEX_AK="" export VE_IMAGEX_SK="" @@ -40,6 +41,7 @@ export VE_IMAGEX_UPLOAD_HOST="https://imagex.volcengineapi.com" # Storage component export STORAGE_TYPE="minio" # minio / tos / s3 +export STORAGE_UPLOAD_HTTP_SCHEME="http" # http / https. If coze studio website is https, you must set it to https export STORAGE_BUCKET="opencoze" # MiniIO export MINIO_ROOT_USER=minioadmin