diff --git a/api/handler/git_http.go b/api/handler/git_http.go index 89dbbbb2d..3ea9037dd 100644 --- a/api/handler/git_http.go +++ b/api/handler/git_http.go @@ -7,6 +7,7 @@ import ( "io" "log/slog" "net/http" + "opencsg.com/csghub-server/common/utils/common" "path/filepath" "strconv" "strings" @@ -244,7 +245,8 @@ func (h *GitHTTPHandler) LfsBatchHF(ctx *gin.Context) { batchRequest.Namespace = ctx.Param("namespace") batchRequest.Name = ctx.Param("name") batchRequest.Name = strings.ReplaceAll(batchRequest.Name, ".git", "") - batchRequest.RepoType = types.RepositoryType(ctx.Param("repo_type")) + + batchRequest.RepoType = common.RepoTypeFromContext(ctx) if batchRequest.RepoType == "" { batchRequest.RepoType = types.ModelRepo } diff --git a/api/router/api.go b/api/router/api.go index 809facc1d..7a1e8446b 100644 --- a/api/router/api.go +++ b/api/router/api.go @@ -1083,6 +1083,17 @@ func createMappingRoutes( { hfdsFileGroup.GET("/:namespace/:name/resolve/:branch/*file_path", middleware.RepoMapping(types.DatasetRepo), repoCommonHandler.SDKDownload) hfdsFileGroup.HEAD("/:namespace/:name/resolve/:branch/*file_path", middleware.RepoMapping(types.DatasetRepo), repoCommonHandler.HeadSDKDownload) + dsLfsGroup := hfdsFileGroup.Group("/:namespace/:name/info/lfs") + dsLfsGroup.Use(middleware.RepoType(types.DatasetRepo)) + { + dsObjectsGroup := dsLfsGroup.Group("/objects") + { + dsObjectsGroup.POST("/batch", gitHTTPHandler.LfsBatchHF) + dsObjectsGroup.PUT("/:oid/:size", gitHTTPHandler.LfsUpload) + dsLfsGroup.GET("/:oid", gitHTTPHandler.LfsDownload) + } + dsObjectsGroup.POST("/verify", gitHTTPHandler.LfsVerify) + } } hfSpaceFileGroup := hfGroup.Group("/spaces") {