Merge branch 'v3dev' of github.com:OpenIMSDK/Open-IM-Server into v3dev

This commit is contained in:
wangchuxiao
2023-07-12 11:33:15 +08:00
9 changed files with 296 additions and 304 deletions
+1 -1
View File
@@ -117,7 +117,7 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
objectGroup.POST("/auth_sign", t.AuthSign)
objectGroup.POST("/complete_multipart_upload", t.CompleteMultipartUpload)
objectGroup.POST("/access_url", t.AccessURL)
objectGroup.GET("/object/*name", t.ObjectRedirect)
objectGroup.GET("/*name", t.ObjectRedirect)
}
//Message
msgGroup := r.Group("/msg", ParseToken)
+7
View File
@@ -55,6 +55,13 @@ func (o *ThirdApi) AccessURL(c *gin.Context) {
func (o *ThirdApi) ObjectRedirect(c *gin.Context) {
name := c.Param("name")
if name == "" {
c.String(http.StatusBadRequest, "name is empty")
return
}
if name[0] == '/' {
name = name[1:]
}
operationID := c.Query("operationID")
if operationID == "" {
operationID = strconv.Itoa(rand.Int())
+4
View File
@@ -4,6 +4,7 @@ import (
"context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cont"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
@@ -29,6 +30,7 @@ func (t *thirdServer) PartSize(ctx context.Context, req *third.PartSizeReq) (*th
}
func (t *thirdServer) InitiateMultipartUpload(ctx context.Context, req *third.InitiateMultipartUploadReq) (*third.InitiateMultipartUploadResp, error) {
defer log.ZDebug(ctx, "return")
if err := checkUploadName(ctx, req.Name); err != nil {
return nil, err
}
@@ -81,6 +83,7 @@ func (t *thirdServer) InitiateMultipartUpload(ctx context.Context, req *third.In
}
func (t *thirdServer) AuthSign(ctx context.Context, req *third.AuthSignReq) (*third.AuthSignResp, error) {
defer log.ZDebug(ctx, "return")
partNumbers := utils.Slice(req.PartNumbers, func(partNumber int32) int { return int(partNumber) })
result, err := t.s3dataBase.AuthSign(ctx, req.UploadID, partNumbers)
if err != nil {
@@ -104,6 +107,7 @@ func (t *thirdServer) AuthSign(ctx context.Context, req *third.AuthSignReq) (*th
}
func (t *thirdServer) CompleteMultipartUpload(ctx context.Context, req *third.CompleteMultipartUploadReq) (*third.CompleteMultipartUploadResp, error) {
defer log.ZDebug(ctx, "return")
if err := checkUploadName(ctx, req.Name); err != nil {
return nil, err
}
+5 -4
View File
@@ -12,12 +12,13 @@ import (
"unicode/utf8"
)
func toPbMapArray(m map[string][]string) map[string]*third.MapValues {
res := make(map[string]*third.MapValues)
func toPbMapArray(m map[string][]string) []*third.KeyValues {
res := make([]*third.KeyValues, 0, len(m))
for key := range m {
res[key] = &third.MapValues{
res = append(res, &third.KeyValues{
Key: key,
Values: m[key],
}
})
}
return res
}