diff --git a/client/internal/http/presigned.go b/client/internal/http/presigned.go index 926ef36..3e4d73d 100644 --- a/client/internal/http/presigned.go +++ b/client/internal/http/presigned.go @@ -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") diff --git a/client/internal/http/server.go b/client/internal/http/server.go index 9726f25..66faf64 100644 --- a/client/internal/http/server.go +++ b/client/internal/http/server.go @@ -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) diff --git a/coordinator/internal/cmd/migrate.go b/coordinator/internal/cmd/migrate.go index 309b832..a73b856 100644 --- a/coordinator/internal/cmd/migrate.go +++ b/coordinator/internal/cmd/migrate.go @@ -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{})