Browse Source

查询对象接口支持预签名

gitlink
Sydonian 7 months ago
parent
commit
2d7d23ad2e
3 changed files with 22 additions and 0 deletions
  1. +20
    -0
      client/internal/http/presigned.go
  2. +1
    -0
      client/internal/http/server.go
  3. +1
    -0
      coordinator/internal/cmd/migrate.go

+ 20
- 0
client/internal/http/presigned.go View File

@@ -27,6 +27,26 @@ func (s *Server) Presigned() *PresignedService {
}
}

func (s *PresignedService) ObjectListByPath(ctx *gin.Context) {
log := logger.WithField("HTTP", "Presigned.ObjectListByPath")

var req cdsapi.PresignedObjectListByPath
if err := ctx.ShouldBindQuery(&req); err != nil {
log.Warnf("binding body: %s", err.Error())
ctx.JSON(http.StatusBadRequest, Failed(errorcode.BadArgument, "missing argument or invalid argument"))
return
}

resp, err := s.svc.ObjectSvc().GetByPath(req.ObjectListByPath)
if err != nil {
log.Warnf("listing objects: %s", err.Error())
ctx.JSON(http.StatusOK, Failed(errorcode.OperationFailed, fmt.Sprintf("listing objects: %v", err)))
return
}

ctx.JSON(http.StatusOK, OK(resp))
}

func (s *PresignedService) ObjectDownloadByPath(ctx *gin.Context) {
log := logger.WithField("HTTP", "Presigned.ObjectDownloadByPath")



+ 1
- 0
client/internal/http/server.go View File

@@ -124,6 +124,7 @@ func (s *Server) routeV1(eg *gin.Engine, rt gin.IRoutes) {
rt.POST(cdsapi.ObjectUploadPartPath, s.Object().UploadPart)
rt.POST(cdsapi.ObjectCompleteMultipartUploadPath, s.Object().CompleteMultipartUpload)

rt.GET(cdsapi.PresignedObjectListByPathPath, s.awsAuth.PresignedAuth, s.Presigned().ObjectListByPath)
rt.GET(cdsapi.PresignedObjectDownloadByPathPath, s.awsAuth.PresignedAuth, s.Presigned().ObjectDownloadByPath)
rt.GET(cdsapi.PresignedObjectDownloadPath, s.awsAuth.PresignedAuth, s.Presigned().ObjectDownload)
rt.POST(cdsapi.PresignedObjectUploadPath, s.awsAuth.PresignedAuth, s.Presigned().ObjectUpload)


+ 1
- 0
coordinator/internal/cmd/migrate.go View File

@@ -40,6 +40,7 @@ func migrate(configPath string) {
fmt.Println(err)
os.Exit(1)
}
db = db.Set("gorm:table_options", "CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci")

migrateOne(db, cdssdk.Bucket{})
migrateOne(db, model.Cache{})


Loading…
Cancel
Save