fix(infra): support configuring the HTTP schema of storage upload in … (#450)
This commit is contained in:
parent
6f305e33aa
commit
568819b8e5
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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: "",
|
||||
|
|
|
|||
|
|
@ -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: "",
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ export REDIS_PASSWORD=""
|
|||
# if imagex, you must finish the configuration of <VolcEngine ImageX>
|
||||
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
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ export REDIS_PASSWORD=""
|
|||
# if imagex, you must finish the configuration of <VolcEngine ImageX>
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue