fix: upload idl split
This commit is contained in:
parent
890153324f
commit
82e55ffdb8
|
|
@ -413,51 +413,3 @@ func GetTypeList(ctx context.Context, c *app.RequestContext) {
|
||||||
|
|
||||||
c.JSON(consts.StatusOK, resp)
|
c.JSON(consts.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommonUpload .
|
|
||||||
// @router /api/playground/upload [POST]
|
|
||||||
func CommonUpload(ctx context.Context, c *app.RequestContext) {
|
|
||||||
var err error
|
|
||||||
var req developer_api.CommonUploadRequest
|
|
||||||
err = c.BindAndValidate(&req)
|
|
||||||
if err != nil {
|
|
||||||
c.String(consts.StatusBadRequest, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fullUrl := string(c.Request.URI().FullURI())
|
|
||||||
resp, err := upload.SVC.UploadFileCommon(ctx, &req, fullUrl)
|
|
||||||
if err != nil {
|
|
||||||
internalServerErrorResponse(ctx, c, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.JSON(consts.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ApplyUploadAction .
|
|
||||||
// @router /api/playground/apply_upload_action [GET]
|
|
||||||
func ApplyUploadAction(ctx context.Context, c *app.RequestContext) {
|
|
||||||
var err error
|
|
||||||
var req developer_api.ApplyUploadActionRequest
|
|
||||||
err = c.BindAndValidate(&req)
|
|
||||||
if err != nil {
|
|
||||||
c.String(consts.StatusBadRequest, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp := new(developer_api.ApplyUploadActionResponse)
|
|
||||||
host := c.Request.Host()
|
|
||||||
if ptr.From(req.Action) == "ApplyImageUpload" {
|
|
||||||
resp, err = upload.SVC.ApplyImageUpload(ctx, &req, string(host))
|
|
||||||
if err != nil {
|
|
||||||
internalServerErrorResponse(ctx, c, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else if ptr.From(req.Action) == "CommitImageUpload" {
|
|
||||||
resp, err = upload.SVC.CommitImageUpload(ctx, &req, string(host))
|
|
||||||
if err != nil {
|
|
||||||
internalServerErrorResponse(ctx, c, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
c.JSON(consts.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
// Code generated by hertz generator.
|
||||||
|
|
||||||
|
package coze
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/cloudwego/hertz/pkg/app"
|
||||||
|
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||||
|
|
||||||
|
upload "github.com/coze-dev/coze-studio/backend/api/model/file/upload"
|
||||||
|
uploadSVC "github.com/coze-dev/coze-studio/backend/application/upload"
|
||||||
|
|
||||||
|
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CommonUpload .
|
||||||
|
// @router /api/common/upload/*tos_uri [POST]
|
||||||
|
func CommonUpload(ctx context.Context, c *app.RequestContext) {
|
||||||
|
var err error
|
||||||
|
var req upload.CommonUploadRequest
|
||||||
|
err = c.BindAndValidate(&req)
|
||||||
|
if err != nil {
|
||||||
|
c.String(consts.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fullUrl := string(c.Request.URI().FullURI())
|
||||||
|
|
||||||
|
resp, err := uploadSVC.SVC.UploadFileCommon(ctx, &req, fullUrl)
|
||||||
|
if err != nil {
|
||||||
|
internalServerErrorResponse(ctx, c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(consts.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ApplyUploadAction .
|
||||||
|
// @router /api/common/upload/apply_upload_action [GET]
|
||||||
|
func ApplyUploadAction(ctx context.Context, c *app.RequestContext) {
|
||||||
|
var err error
|
||||||
|
var req upload.ApplyUploadActionRequest
|
||||||
|
err = c.BindAndValidate(&req)
|
||||||
|
if err != nil {
|
||||||
|
c.String(consts.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp := new(upload.ApplyUploadActionResponse)
|
||||||
|
host := c.Request.Host()
|
||||||
|
if ptr.From(req.Action) == "ApplyImageUpload" {
|
||||||
|
resp, err = uploadSVC.SVC.ApplyImageUpload(ctx, &req, string(host))
|
||||||
|
if err != nil {
|
||||||
|
internalServerErrorResponse(ctx, c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else if ptr.From(req.Action) == "CommitImageUpload" {
|
||||||
|
resp, err = uploadSVC.SVC.CommitImageUpload(ctx, &req, string(host))
|
||||||
|
if err != nil {
|
||||||
|
internalServerErrorResponse(ctx, c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(consts.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
@ -3,10 +3,12 @@
|
||||||
package coze
|
package coze
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/apache/thrift/lib/go/thrift"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/agentrun"
|
"github.com/coze-dev/coze-studio/backend/api/model/conversation/agentrun"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/conversation"
|
"github.com/coze-dev/coze-studio/backend/api/model/conversation/conversation"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/message"
|
"github.com/coze-dev/coze-studio/backend/api/model/conversation/message"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/database"
|
"github.com/coze-dev/coze-studio/backend/api/model/database"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/api/model/file/upload"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/flow/dataengine/dataset"
|
"github.com/coze-dev/coze-studio/backend/api/model/flow/dataengine/dataset"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/flow/marketplace/product_public_api"
|
"github.com/coze-dev/coze-studio/backend/api/model/flow/marketplace/product_public_api"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/intelligence"
|
"github.com/coze-dev/coze-studio/backend/api/model/intelligence"
|
||||||
|
|
@ -19,7 +21,6 @@ import (
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/passport"
|
"github.com/coze-dev/coze-studio/backend/api/model/passport"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/permission/openapiauth"
|
"github.com/coze-dev/coze-studio/backend/api/model/permission/openapiauth"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/resource"
|
"github.com/coze-dev/coze-studio/backend/api/model/resource"
|
||||||
"github.com/apache/thrift/lib/go/thrift"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type IntelligenceService interface {
|
type IntelligenceService interface {
|
||||||
|
|
@ -438,6 +439,32 @@ func NewBotOpenApiServiceClient(c thrift.TClient) *BotOpenApiServiceClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UploadService interface {
|
||||||
|
upload.UploadService
|
||||||
|
}
|
||||||
|
|
||||||
|
type UploadServiceClient struct {
|
||||||
|
*upload.UploadServiceClient
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUploadServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *UploadServiceClient {
|
||||||
|
return &UploadServiceClient{
|
||||||
|
UploadServiceClient: upload.NewUploadServiceClientFactory(t, f),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUploadServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *UploadServiceClient {
|
||||||
|
return &UploadServiceClient{
|
||||||
|
UploadServiceClient: upload.NewUploadServiceClientProtocol(t, iprot, oprot),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUploadServiceClient(c thrift.TClient) *UploadServiceClient {
|
||||||
|
return &UploadServiceClient{
|
||||||
|
UploadServiceClient: upload.NewUploadServiceClient(c),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type IntelligenceServiceProcessor struct {
|
type IntelligenceServiceProcessor struct {
|
||||||
*intelligence.IntelligenceServiceProcessor
|
*intelligence.IntelligenceServiceProcessor
|
||||||
}
|
}
|
||||||
|
|
@ -581,3 +608,12 @@ func NewBotOpenApiServiceProcessor(handler BotOpenApiService) *BotOpenApiService
|
||||||
self := &BotOpenApiServiceProcessor{bot_open_api.NewBotOpenApiServiceProcessor(handler)}
|
self := &BotOpenApiServiceProcessor{bot_open_api.NewBotOpenApiServiceProcessor(handler)}
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UploadServiceProcessor struct {
|
||||||
|
*upload.UploadServiceProcessor
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUploadServiceProcessor(handler UploadService) *UploadServiceProcessor {
|
||||||
|
self := &UploadServiceProcessor{upload.NewUploadServiceProcessor(handler)}
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -24,6 +24,15 @@ func Register(r *server.Hertz) {
|
||||||
_bot.POST("/get_type_list", append(_gettypelistMw(), coze.GetTypeList)...)
|
_bot.POST("/get_type_list", append(_gettypelistMw(), coze.GetTypeList)...)
|
||||||
_bot.POST("/upload_file", append(_uploadfileMw(), coze.UploadFile)...)
|
_bot.POST("/upload_file", append(_uploadfileMw(), coze.UploadFile)...)
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
_common := _api.Group("/common", _commonMw()...)
|
||||||
|
{
|
||||||
|
_upload := _common.Group("/upload", _uploadMw()...)
|
||||||
|
_upload.GET("/apply_upload_action", append(_applyuploadactionMw(), coze.ApplyUploadAction)...)
|
||||||
|
_upload.POST("/apply_upload_action", append(_applyuploadaction0Mw(), coze.ApplyUploadAction)...)
|
||||||
|
_upload.POST("/*tos_uri", append(_commonuploadMw(), coze.CommonUpload)...)
|
||||||
|
}
|
||||||
|
}
|
||||||
{
|
{
|
||||||
_conversation := _api.Group("/conversation", _conversationMw()...)
|
_conversation := _api.Group("/conversation", _conversationMw()...)
|
||||||
_conversation.POST("/break_message", append(_breakmessageMw(), coze.BreakMessage)...)
|
_conversation.POST("/break_message", append(_breakmessageMw(), coze.BreakMessage)...)
|
||||||
|
|
@ -252,13 +261,10 @@ func Register(r *server.Hertz) {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
_playground := _api.Group("/playground", _playgroundMw()...)
|
_playground := _api.Group("/playground", _playgroundMw()...)
|
||||||
_playground.GET("/apply_upload_action", append(_applyuploadactionMw(), coze.ApplyUploadAction)...)
|
|
||||||
_playground.POST("/apply_upload_action", append(_applyuploadaction0Mw(), coze.ApplyUploadAction)...)
|
|
||||||
_playground.POST("/get_onboarding", append(_getonboardingMw(), coze.GetOnboarding)...)
|
_playground.POST("/get_onboarding", append(_getonboardingMw(), coze.GetOnboarding)...)
|
||||||
{
|
{
|
||||||
_upload := _playground.Group("/upload", _uploadMw()...)
|
_upload0 := _playground.Group("/upload", _upload0Mw()...)
|
||||||
_upload.POST("/auth_token", append(_getuploadauthtokenMw(), coze.GetUploadAuthToken)...)
|
_upload0.POST("/auth_token", append(_getuploadauthtokenMw(), coze.GetUploadAuthToken)...)
|
||||||
_upload.POST("/*tos_uri", append(_commonuploadMw(), coze.CommonUpload)...)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
@ -395,8 +401,8 @@ func Register(r *server.Hertz) {
|
||||||
_project_conversation.POST("/update", append(_updateprojectconversationdefMw(), coze.UpdateProjectConversationDef)...)
|
_project_conversation.POST("/update", append(_updateprojectconversationdefMw(), coze.UpdateProjectConversationDef)...)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
_upload0 := _workflow_api.Group("/upload", _upload0Mw()...)
|
_upload1 := _workflow_api.Group("/upload", _upload1Mw()...)
|
||||||
_upload0.POST("/auth_token", append(_getworkflowuploadauthtokenMw(), coze.GetWorkflowUploadAuthToken)...)
|
_upload1.POST("/auth_token", append(_getworkflowuploadauthtokenMw(), coze.GetWorkflowUploadAuthToken)...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1495,3 +1495,13 @@ func _applyuploadaction0Mw() []app.HandlerFunc {
|
||||||
// your code...
|
// your code...
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _commonMw() []app.HandlerFunc {
|
||||||
|
// your code...
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func _upload1Mw() []app.HandlerFunc {
|
||||||
|
// your code...
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ import (
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
|
||||||
|
"github.com/coze-dev/coze-studio/backend/api/model/file/upload"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/flow/dataengine/dataset"
|
"github.com/coze-dev/coze-studio/backend/api/model/flow/dataengine/dataset"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/developer_api"
|
"github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/developer_api"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/playground"
|
"github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/playground"
|
||||||
|
|
@ -263,9 +264,9 @@ func stringToMap(input string) map[string]string {
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
func (u *UploadService) UploadFileCommon(ctx context.Context, req *developer_api.CommonUploadRequest, fullPath string) (*developer_api.CommonUploadResponse, error) {
|
func (u *UploadService) UploadFileCommon(ctx context.Context, req *upload.CommonUploadRequest, fullPath string) (*upload.CommonUploadResponse, error) {
|
||||||
resp := developer_api.NewCommonUploadResponse()
|
resp := upload.NewCommonUploadResponse()
|
||||||
re := regexp.MustCompile(`/api/playground/upload/([^?]+)`)
|
re := regexp.MustCompile(consts.UploadURI + `/([^?]+)`)
|
||||||
match := re.FindStringSubmatch(fullPath)
|
match := re.FindStringSubmatch(fullPath)
|
||||||
if len(match) == 0 {
|
if len(match) == 0 {
|
||||||
return nil, errorx.New(errno.ErrUploadInvalidParamCode, errorx.KV("msg", "tos key not found"))
|
return nil, errorx.New(errno.ErrUploadInvalidParamCode, errorx.KV("msg", "tos key not found"))
|
||||||
|
|
@ -276,8 +277,8 @@ func (u *UploadService) UploadFileCommon(ctx context.Context, req *developer_api
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return resp, errorx.New(errno.ErrUploadSystemErrorCode, errorx.KV("msg", err.Error()))
|
return resp, errorx.New(errno.ErrUploadSystemErrorCode, errorx.KV("msg", err.Error()))
|
||||||
}
|
}
|
||||||
resp.Error = &developer_api.Error{Code: 200}
|
resp.Error = &upload.Error{Code: 200}
|
||||||
resp.Payload = &developer_api.Payload{UploadID: uploadID}
|
resp.Payload = &upload.Payload{UploadID: uploadID}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
if len(ptr.From(req.PartNumber)) != 0 {
|
if len(ptr.From(req.PartNumber)) != 0 {
|
||||||
|
|
@ -289,7 +290,7 @@ func (u *UploadService) UploadFileCommon(ctx context.Context, req *developer_api
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return resp, errorx.New(errno.ErrUploadSystemErrorCode, errorx.KV("msg", err.Error()))
|
return resp, errorx.New(errno.ErrUploadSystemErrorCode, errorx.KV("msg", err.Error()))
|
||||||
}
|
}
|
||||||
resp.Error = &developer_api.Error{Code: 200}
|
resp.Error = &upload.Error{Code: 200}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
if len(ptr.From(req.UploadID)) != 0 {
|
if len(ptr.From(req.UploadID)) != 0 {
|
||||||
|
|
@ -302,8 +303,8 @@ func (u *UploadService) UploadFileCommon(ctx context.Context, req *developer_api
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return resp, errorx.New(errno.ErrUploadSystemErrorCode, errorx.KV("msg", err.Error()))
|
return resp, errorx.New(errno.ErrUploadSystemErrorCode, errorx.KV("msg", err.Error()))
|
||||||
}
|
}
|
||||||
resp.Error = &developer_api.Error{Code: 200}
|
resp.Error = &upload.Error{Code: 200}
|
||||||
resp.Payload = &developer_api.Payload{Key: uuid.NewString()}
|
resp.Payload = &upload.Payload{Key: uuid.NewString()}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
|
|
@ -316,8 +317,8 @@ func (u *UploadService) UploadFileCommon(ctx context.Context, req *developer_api
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return resp, errorx.New(errno.ErrUploadSystemErrorCode, errorx.KV("msg", err.Error()))
|
return resp, errorx.New(errno.ErrUploadSystemErrorCode, errorx.KV("msg", err.Error()))
|
||||||
}
|
}
|
||||||
resp.Error = &developer_api.Error{Code: 200}
|
resp.Error = &upload.Error{Code: 200}
|
||||||
resp.Payload = &developer_api.Payload{Key: uuid.NewString()}
|
resp.Payload = &upload.Payload{Key: uuid.NewString()}
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -614,23 +615,23 @@ func isSVG(uri string) bool {
|
||||||
ext = ext[1:]
|
ext = ext[1:]
|
||||||
return ext == "svg"
|
return ext == "svg"
|
||||||
}
|
}
|
||||||
func (u *UploadService) ApplyImageUpload(ctx context.Context, req *developer_api.ApplyUploadActionRequest, host string) (*developer_api.ApplyUploadActionResponse, error) {
|
func (u *UploadService) ApplyImageUpload(ctx context.Context, req *upload.ApplyUploadActionRequest, host string) (*upload.ApplyUploadActionResponse, error) {
|
||||||
resp := developer_api.ApplyUploadActionResponse{}
|
resp := upload.ApplyUploadActionResponse{}
|
||||||
storeUri := "tos-cn-i-v4nquku3lp/" + uuid.NewString() + ptr.From(req.FileExtension)
|
storeUri := "tos-cn-i-v4nquku3lp/" + uuid.NewString() + ptr.From(req.FileExtension)
|
||||||
sessionKey := uuid.NewString()
|
sessionKey := uuid.NewString()
|
||||||
auth := uuid.NewString()
|
auth := uuid.NewString()
|
||||||
uploadID := uuid.NewString()
|
uploadID := uuid.NewString()
|
||||||
uploadHost := string(host) + consts.UploadURI
|
uploadHost := string(host) + consts.UploadURI
|
||||||
resp.ResponseMetadata = &developer_api.ResponseMetadata{
|
resp.ResponseMetadata = &upload.ResponseMetadata{
|
||||||
RequestId: uuid.NewString(),
|
RequestId: uuid.NewString(),
|
||||||
Action: "ApplyImageUpload",
|
Action: "ApplyImageUpload",
|
||||||
Version: "",
|
Version: "",
|
||||||
Service: "",
|
Service: "",
|
||||||
Region: "",
|
Region: "",
|
||||||
}
|
}
|
||||||
resp.Result = &developer_api.ApplyUploadActionResult{
|
resp.Result = &upload.ApplyUploadActionResult{
|
||||||
UploadAddress: &developer_api.UploadAddress{
|
UploadAddress: &upload.UploadAddress{
|
||||||
StoreInfos: []*developer_api.StoreInfo{
|
StoreInfos: []*upload.StoreInfo{
|
||||||
{
|
{
|
||||||
StoreUri: storeUri,
|
StoreUri: storeUri,
|
||||||
Auth: auth,
|
Auth: auth,
|
||||||
|
|
@ -640,10 +641,10 @@ func (u *UploadService) ApplyImageUpload(ctx context.Context, req *developer_api
|
||||||
UploadHosts: []string{uploadHost},
|
UploadHosts: []string{uploadHost},
|
||||||
SessionKey: sessionKey,
|
SessionKey: sessionKey,
|
||||||
},
|
},
|
||||||
InnerUploadAddress: &developer_api.InnerUploadAddress{
|
InnerUploadAddress: &upload.InnerUploadAddress{
|
||||||
UploadNodes: []*developer_api.UploadNode{
|
UploadNodes: []*upload.UploadNode{
|
||||||
{
|
{
|
||||||
StoreInfos: []*developer_api.StoreInfo{
|
StoreInfos: []*upload.StoreInfo{
|
||||||
{
|
{
|
||||||
StoreUri: storeUri,
|
StoreUri: storeUri,
|
||||||
Auth: auth,
|
Auth: auth,
|
||||||
|
|
@ -664,8 +665,8 @@ func (u *UploadService) ApplyImageUpload(ctx context.Context, req *developer_api
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UploadService) CommitImageUpload(ctx context.Context, req *developer_api.ApplyUploadActionRequest, host string) (*developer_api.ApplyUploadActionResponse, error) {
|
func (u *UploadService) CommitImageUpload(ctx context.Context, req *upload.ApplyUploadActionRequest, host string) (*upload.ApplyUploadActionResponse, error) {
|
||||||
resp := developer_api.ApplyUploadActionResponse{}
|
resp := upload.ApplyUploadActionResponse{}
|
||||||
type ssKey struct {
|
type ssKey struct {
|
||||||
SessionKey string `json:"SessionKey"`
|
SessionKey string `json:"SessionKey"`
|
||||||
}
|
}
|
||||||
|
|
@ -678,22 +679,22 @@ func (u *UploadService) CommitImageUpload(ctx context.Context, req *developer_ap
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &resp, errorx.New(errno.ErrUploadSystemErrorCode, errorx.KV("msg", err.Error()))
|
return &resp, errorx.New(errno.ErrUploadSystemErrorCode, errorx.KV("msg", err.Error()))
|
||||||
}
|
}
|
||||||
resp.ResponseMetadata = &developer_api.ResponseMetadata{
|
resp.ResponseMetadata = &upload.ResponseMetadata{
|
||||||
RequestId: uuid.NewString(),
|
RequestId: uuid.NewString(),
|
||||||
Action: "ApplyImageUpload",
|
Action: "ApplyImageUpload",
|
||||||
Version: "",
|
Version: "",
|
||||||
Service: "",
|
Service: "",
|
||||||
Region: "",
|
Region: "",
|
||||||
}
|
}
|
||||||
resp.Result = &developer_api.ApplyUploadActionResult{
|
resp.Result = &upload.ApplyUploadActionResult{
|
||||||
Results: []*developer_api.UploadResult{
|
Results: []*upload.UploadResult{
|
||||||
{
|
{
|
||||||
Uri: objInfo.ObjKey,
|
Uri: objInfo.ObjKey,
|
||||||
UriStatus: 2000,
|
UriStatus: 2000,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
RequestId: ptr.Of(uuid.NewString()),
|
RequestId: ptr.Of(uuid.NewString()),
|
||||||
PluginResult: []*developer_api.PluginResult{
|
PluginResult: []*upload.PluginResult{
|
||||||
{
|
{
|
||||||
FileName: objInfo.ObjKey,
|
FileName: objInfo.ObjKey,
|
||||||
SourceUri: objInfo.ObjKey,
|
SourceUri: objInfo.ObjKey,
|
||||||
|
|
|
||||||
|
|
@ -49,14 +49,14 @@ type minioClient struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStorageImagex(ctx context.Context, endpoint, accessKeyID, secretAccessKey, bucketName string, useSSL bool) (imagex.ImageX, error) {
|
func NewStorageImagex(ctx context.Context, endpoint, accessKeyID, secretAccessKey, bucketName string, useSSL bool) (imagex.ImageX, error) {
|
||||||
m, err := minoClient(ctx, endpoint, accessKeyID, secretAccessKey, bucketName, useSSL)
|
m, err := getMinioClient(ctx, endpoint, accessKeyID, secretAccessKey, bucketName, useSSL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func minoClient(_ context.Context, endpoint, accessKeyID, secretAccessKey, bucketName string, useSSL bool) (*minioClient, error) {
|
func getMinioClient(_ context.Context, endpoint, accessKeyID, secretAccessKey, bucketName string, useSSL bool) (*minioClient, error) {
|
||||||
client, err := minio.New(endpoint, &minio.Options{
|
client, err := minio.New(endpoint, &minio.Options{
|
||||||
Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""),
|
Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""),
|
||||||
Secure: useSSL,
|
Secure: useSSL,
|
||||||
|
|
@ -81,7 +81,7 @@ func minoClient(_ context.Context, endpoint, accessKeyID, secretAccessKey, bucke
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(ctx context.Context, endpoint, accessKeyID, secretAccessKey, bucketName string, useSSL bool) (storage.Storage, error) {
|
func New(ctx context.Context, endpoint, accessKeyID, secretAccessKey, bucketName string, useSSL bool) (storage.Storage, error) {
|
||||||
m, err := minoClient(ctx, endpoint, accessKeyID, secretAccessKey, bucketName, useSSL)
|
m, err := getMinioClient(ctx, endpoint, accessKeyID, secretAccessKey, bucketName, useSSL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,6 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ApplyUploadActionURI = "/api/playground/apply_upload_action"
|
ApplyUploadActionURI = "/api/common/upload/apply_upload_action"
|
||||||
UploadURI = "/api/playground/upload"
|
UploadURI = "/api/common/upload"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ include "./resource/resource.thrift"
|
||||||
include "./passport/passport.thrift"
|
include "./passport/passport.thrift"
|
||||||
include "./bot_platform/ocean_cloud_workflow/ocean_cloud_workflow.thrift"
|
include "./bot_platform/ocean_cloud_workflow/ocean_cloud_workflow.thrift"
|
||||||
include "./bot_open_api/bot_open_api.thrift"
|
include "./bot_open_api/bot_open_api.thrift"
|
||||||
|
include "./upload/upload.thrift"
|
||||||
|
|
||||||
|
|
||||||
namespace go coze
|
namespace go coze
|
||||||
|
|
||||||
|
|
@ -40,3 +42,4 @@ service PassportService extends passport.PassportService {}
|
||||||
service WorkflowService extends ocean_cloud_workflow.WorkflowService {}
|
service WorkflowService extends ocean_cloud_workflow.WorkflowService {}
|
||||||
service KnowledgeService extends flow_dataengine_dataset.DatasetService {}
|
service KnowledgeService extends flow_dataengine_dataset.DatasetService {}
|
||||||
service BotOpenApiService extends bot_open_api.BotOpenApiService {}
|
service BotOpenApiService extends bot_open_api.BotOpenApiService {}
|
||||||
|
service UploadService extends upload.UploadService {}
|
||||||
|
|
|
||||||
|
|
@ -4,48 +4,6 @@ include "../playground/shortcut_command.thrift"
|
||||||
|
|
||||||
namespace go ocean.cloud.developer_api
|
namespace go ocean.cloud.developer_api
|
||||||
|
|
||||||
struct CommonUploadRequest {
|
|
||||||
1: optional binary ByteData (api.raw_body = "")
|
|
||||||
2: optional string uploadID (api.query="uploadID")
|
|
||||||
3: optional string partNumber (api.query="partNumber")
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Meta {
|
|
||||||
1: string ObjectContentType
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Crc32Data {
|
|
||||||
1: string crc32
|
|
||||||
2: string mode
|
|
||||||
3: string hash
|
|
||||||
4: string key
|
|
||||||
5: string uploadid
|
|
||||||
6: string part_number
|
|
||||||
7: string etag
|
|
||||||
8: Meta meta
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Error{
|
|
||||||
1: i32 code,
|
|
||||||
2: string error,
|
|
||||||
3: i32 error_code,
|
|
||||||
4: string message
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Payload{
|
|
||||||
1: string hash,
|
|
||||||
2: string key,
|
|
||||||
3: string uploadID
|
|
||||||
}
|
|
||||||
|
|
||||||
struct CommonUploadResponse {
|
|
||||||
1: string Version
|
|
||||||
2: i32 success
|
|
||||||
3: Error error
|
|
||||||
4: Payload payload
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct DraftBotCreateRequest {
|
struct DraftBotCreateRequest {
|
||||||
1: required i64 space_id (agw.js_conv="str", api.js_conv="true")
|
1: required i64 space_id (agw.js_conv="str", api.js_conv="true")
|
||||||
|
|
@ -915,84 +873,10 @@ struct PublishConnectorListResponse {
|
||||||
7: optional PublishTips publish_tips // 发布提醒
|
7: optional PublishTips publish_tips // 发布提醒
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ResponseMetadata {
|
|
||||||
1: required string RequestId,
|
|
||||||
2: required string Action,
|
|
||||||
3: required string Version,
|
|
||||||
4: required string Service,
|
|
||||||
5: required string Region
|
|
||||||
}
|
|
||||||
|
|
||||||
struct StoreInfo {
|
|
||||||
1: required string StoreUri,
|
|
||||||
2: required string Auth,
|
|
||||||
3: required string UploadID
|
|
||||||
}
|
|
||||||
|
|
||||||
struct UploadAddress {
|
|
||||||
1: required list<StoreInfo> StoreInfos,
|
|
||||||
2: required list<string> UploadHosts,
|
|
||||||
3: optional map<string, string> UploadHeader,
|
|
||||||
4: required string SessionKey,
|
|
||||||
5: required string Cloud
|
|
||||||
}
|
|
||||||
|
|
||||||
struct UploadNode {
|
|
||||||
1: required list<StoreInfo> StoreInfos,
|
|
||||||
2: required string UploadHost,
|
|
||||||
3: optional map<string, string> UploadHeader,
|
|
||||||
4: required string SessionKey
|
|
||||||
}
|
|
||||||
|
|
||||||
struct InnerUploadAddress {
|
|
||||||
1: required list<UploadNode> UploadNodes
|
|
||||||
}
|
|
||||||
|
|
||||||
struct UploadResult {
|
|
||||||
1: required string Uri,
|
|
||||||
2: required i32 UriStatus
|
|
||||||
}
|
|
||||||
|
|
||||||
struct PluginResult {
|
|
||||||
1: required string FileName,
|
|
||||||
2: required string SourceUri,
|
|
||||||
3: required string ImageUri,
|
|
||||||
4: required i32 ImageWidth,
|
|
||||||
5: required i32 ImageHeight,
|
|
||||||
6: required string ImageMd5,
|
|
||||||
7: required string ImageFormat,
|
|
||||||
8: required i32 ImageSize,
|
|
||||||
9: required i32 FrameCnt
|
|
||||||
}
|
|
||||||
struct ApplyUploadActionResult {
|
|
||||||
1: optional UploadAddress UploadAddress,
|
|
||||||
2: optional UploadAddress FallbackUploadAddress,
|
|
||||||
3: optional InnerUploadAddress InnerUploadAddress,
|
|
||||||
4: optional string RequestId,
|
|
||||||
5: optional string SDKParam
|
|
||||||
6: optional list<UploadResult> Results,
|
|
||||||
7: optional list<PluginResult> PluginResult
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ApplyUploadActionResponse {
|
|
||||||
1: required ResponseMetadata ResponseMetadata,
|
|
||||||
2: required ApplyUploadActionResult Result
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ApplyUploadActionRequest {
|
|
||||||
1: optional string Action (api.query="Action"),
|
|
||||||
2: optional string Version (api.query="Version"),
|
|
||||||
3: optional string ServiceId (api.query="ServiceId"),
|
|
||||||
4: optional string FileExtension (api.query="FileExtension")
|
|
||||||
5: optional string FileSize (api.query="FileSize")
|
|
||||||
6: optional string s (api.query="s")
|
|
||||||
7: optional binary ByteData (api.raw_body = "")
|
|
||||||
}
|
|
||||||
|
|
||||||
service DeveloperApiService {
|
service DeveloperApiService {
|
||||||
|
|
||||||
GetUploadAuthTokenResponse GetUploadAuthToken(1: GetUploadAuthTokenRequest request)(api.post = '/api/playground/upload/auth_token', api.category="playground", api.gen_path="playground")
|
GetUploadAuthTokenResponse GetUploadAuthToken(1: GetUploadAuthTokenRequest request)(api.post = '/api/playground/upload/auth_token', api.category="playground", api.gen_path="playground")
|
||||||
CommonUploadResponse CommonUpload(1: CommonUploadRequest request)(api.post = '/api/playground/upload/*tos_uri', api.category="playground", api.gen_path="playground")
|
|
||||||
DeleteDraftBotResponse DeleteDraftBot(1:DeleteDraftBotRequest request)(api.post='/api/draftbot/delete', api.category="draftbot", api.gen_path="draftbot")
|
DeleteDraftBotResponse DeleteDraftBot(1:DeleteDraftBotRequest request)(api.post='/api/draftbot/delete', api.category="draftbot", api.gen_path="draftbot")
|
||||||
DuplicateDraftBotResponse DuplicateDraftBot(1:DuplicateDraftBotRequest request)(api.post='/api/draftbot/duplicate', api.category="draftbot", api.gen_path="draftbot")
|
DuplicateDraftBotResponse DuplicateDraftBot(1:DuplicateDraftBotRequest request)(api.post='/api/draftbot/duplicate', api.category="draftbot", api.gen_path="draftbot")
|
||||||
CheckDraftBotCommitResponse CheckDraftBotCommit(1:CheckDraftBotCommitRequest request)(api.post='/api/draftbot/commit_check', api.category="draftbot", api.gen_path="draftbot")
|
CheckDraftBotCommitResponse CheckDraftBotCommit(1:CheckDraftBotCommitRequest request)(api.post='/api/draftbot/commit_check', api.category="draftbot", api.gen_path="draftbot")
|
||||||
|
|
@ -1012,6 +896,4 @@ service DeveloperApiService {
|
||||||
|
|
||||||
UpdateUserProfileCheckResponse UpdateUserProfileCheck(1: UpdateUserProfileCheckRequest request)(api.post='/api/user/update_profile_check', api.category="user", api.gen_path="user")
|
UpdateUserProfileCheckResponse UpdateUserProfileCheck(1: UpdateUserProfileCheckRequest request)(api.post='/api/user/update_profile_check', api.category="user", api.gen_path="user")
|
||||||
|
|
||||||
ApplyUploadActionResponse ApplyUploadAction(1: ApplyUploadActionRequest request)(api.get='/api/playground/apply_upload_action', api.post='/api/playground/apply_upload_action', api.category="playground", api.gen_path="playground")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
include "../base.thrift"
|
||||||
|
include "../bot_common/bot_common.thrift"
|
||||||
|
namespace go file.upload
|
||||||
|
struct CommonUploadRequest {
|
||||||
|
1: optional binary ByteData (api.raw_body = "")
|
||||||
|
2: optional string uploadID (api.query="uploadID")
|
||||||
|
3: optional string partNumber (api.query="partNumber")
|
||||||
|
}
|
||||||
|
struct Error{
|
||||||
|
1: i32 code,
|
||||||
|
2: string error,
|
||||||
|
3: i32 error_code,
|
||||||
|
4: string message
|
||||||
|
}
|
||||||
|
struct Payload{
|
||||||
|
1: string hash,
|
||||||
|
2: string key,
|
||||||
|
3: string uploadID
|
||||||
|
}
|
||||||
|
struct CommonUploadResponse {
|
||||||
|
1: string Version
|
||||||
|
2: i32 success
|
||||||
|
3: Error error
|
||||||
|
4: Payload payload
|
||||||
|
}
|
||||||
|
struct ApplyUploadActionRequest {
|
||||||
|
1: optional string Action (api.query="Action"),
|
||||||
|
2: optional string Version (api.query="Version"),
|
||||||
|
3: optional string ServiceId (api.query="ServiceId"),
|
||||||
|
4: optional string FileExtension (api.query="FileExtension")
|
||||||
|
5: optional string FileSize (api.query="FileSize")
|
||||||
|
6: optional string s (api.query="s")
|
||||||
|
7: optional binary ByteData (api.raw_body = "")
|
||||||
|
}
|
||||||
|
struct ResponseMetadata {
|
||||||
|
1: required string RequestId,
|
||||||
|
2: required string Action,
|
||||||
|
3: required string Version,
|
||||||
|
4: required string Service,
|
||||||
|
5: required string Region
|
||||||
|
}
|
||||||
|
struct StoreInfo {
|
||||||
|
1: required string StoreUri,
|
||||||
|
2: required string Auth,
|
||||||
|
3: required string UploadID
|
||||||
|
}
|
||||||
|
struct UploadAddress {
|
||||||
|
1: required list<StoreInfo> StoreInfos,
|
||||||
|
2: required list<string> UploadHosts,
|
||||||
|
3: optional map<string, string> UploadHeader,
|
||||||
|
4: required string SessionKey,
|
||||||
|
5: required string Cloud
|
||||||
|
}
|
||||||
|
struct UploadNode {
|
||||||
|
1: required list<StoreInfo> StoreInfos,
|
||||||
|
2: required string UploadHost,
|
||||||
|
3: optional map<string, string> UploadHeader,
|
||||||
|
4: required string SessionKey
|
||||||
|
}
|
||||||
|
struct InnerUploadAddress {
|
||||||
|
1: required list<UploadNode> UploadNodes
|
||||||
|
}
|
||||||
|
struct UploadResult {
|
||||||
|
1: required string Uri,
|
||||||
|
2: required i32 UriStatus
|
||||||
|
}
|
||||||
|
struct PluginResult {
|
||||||
|
1: required string FileName,
|
||||||
|
2: required string SourceUri,
|
||||||
|
3: required string ImageUri,
|
||||||
|
4: required i32 ImageWidth,
|
||||||
|
5: required i32 ImageHeight,
|
||||||
|
6: required string ImageMd5,
|
||||||
|
7: required string ImageFormat,
|
||||||
|
8: required i32 ImageSize,
|
||||||
|
9: required i32 FrameCnt
|
||||||
|
}
|
||||||
|
struct ApplyUploadActionResult {
|
||||||
|
1: optional UploadAddress UploadAddress,
|
||||||
|
2: optional UploadAddress FallbackUploadAddress,
|
||||||
|
3: optional InnerUploadAddress InnerUploadAddress,
|
||||||
|
4: optional string RequestId,
|
||||||
|
5: optional string SDKParam
|
||||||
|
6: optional list<UploadResult> Results,
|
||||||
|
7: optional list<PluginResult> PluginResult
|
||||||
|
}
|
||||||
|
struct ApplyUploadActionResponse {
|
||||||
|
1: required ResponseMetadata ResponseMetadata,
|
||||||
|
2: required ApplyUploadActionResult Result
|
||||||
|
}
|
||||||
|
service UploadService {
|
||||||
|
CommonUploadResponse CommonUpload(1: CommonUploadRequest request)(api.post = '/api/common/upload/*tos_uri', api.category="upload", api.gen_path="upload")
|
||||||
|
ApplyUploadActionResponse ApplyUploadAction(1: ApplyUploadActionRequest request)(api.get='/api/common/upload/apply_upload_action', api.post='/api/common/upload/apply_upload_action', api.category="common", api.gen_path="common")
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue