MCPcopy Index your code
hub / github.com/53AI/53AIHub / GetSkillFileContent

Function GetSkillFileContent

api/controller/skill_library_admin.go:633–661  ·  view source on GitHub ↗

GetSkillFileContent godoc @Summary 获取技能文件内容 @Description 获取技能包内指定文件的文本内容 @Tags 技能库-后台 @Accept json @Produce json @Security BearerAuth @Param id path int true "技能ID" @Param path path string true "文件相对路径" @Success 200 {object} model.CommonResponse{data=controller.SkillFileContentResponse} @Router /api

(c *gin.Context)

Source from the content-addressed store, hash-verified

631// @Success 200 {object} model.CommonResponse{data=controller.SkillFileContentResponse}
632// @Router /api/admin/skill-library/{id}/files/{path} [get]
633func GetSkillFileContent(c *gin.Context) {
634 skillID, err := strconv.ParseInt(c.Param("id"), 10, 64)
635 if err != nil || skillID <= 0 {
636 c.JSON(http.StatusBadRequest, model.ParamError.ToResponse(nil))
637 return
638 }
639
640 filePath := c.Param("path")
641 if filePath == "" {
642 c.JSON(http.StatusBadRequest, model.ParamError.ToErrorResponse(errors.New("file path is required")))
643 return
644 }
645 filePath = strings.TrimPrefix(filePath, "/")
646
647 eid := config.GetEID(c)
648 svc := service.NewSkillLibraryService()
649
650 content, err := svc.GetSkillFileContent(c.Request.Context(), eid, skillID, filePath)
651 if err != nil {
652 toSkillAdminErrorResponse(c, err)
653 return
654 }
655
656 c.JSON(http.StatusOK, model.Success.ToResponse(&SkillFileContentResponse{
657 Path: filePath,
658 Content: content,
659 Size: int64(len(content)),
660 }))
661}
662
663// PreviewSkillFile godoc
664// @Summary 预览技能文件

Callers

nothing calls this directly

Calls 6

GetSkillFileContentMethod · 0.95
ToResponseMethod · 0.80
ToErrorResponseMethod · 0.80
GetEIDMethod · 0.80
NewMethod · 0.45

Tested by

no test coverage detected