From 2d7d23ad2e51e6bc95b4640e9cb8fcf226733604 Mon Sep 17 00:00:00 2001 From: Sydonian <794346190@qq.com> Date: Thu, 27 Mar 2025 11:11:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=AF=B9=E8=B1=A1=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=94=AF=E6=8C=81=E9=A2=84=E7=AD=BE=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/internal/http/presigned.go | 20 ++++++++++++++++++++ client/internal/http/server.go | 1 + coordinator/internal/cmd/migrate.go | 1 + 3 files changed, 22 insertions(+) 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{})