转存指定对应文件

This commit is contained in:
TsMask
2023-12-04 18:34:37 +08:00
parent e11da6c904
commit 0357b137bc

View File

@@ -77,13 +77,14 @@ func (s *CommontController) SysConfig(c *gin.Context) {
c.JSON(200, result.OkData(data))
}
// 转存帮助文档
// 转存指定对应文件
//
// POST /helpDoc
func (s *CommontController) HelpDoc(c *gin.Context) {
// POST /transferStaticFile
func (s *CommontController) TransferStaticFile(c *gin.Context) {
language := ctx.AcceptLanguage(c)
var body struct {
UploadPath string `json:"uploadPath" binding:"required"`
StaticPath string `json:"staticPath" binding:"required"`
Language string `json:"language" binding:"required"`
}
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
@@ -102,8 +103,9 @@ func (s *CommontController) HelpDoc(c *gin.Context) {
return
}
newFile := fmt.Sprintf("%s/helpDoc/%s_doc.pdf", dir, lang)
fmt.Println(newFile)
delPrefix := strings.Replace(body.StaticPath, static["prefix"].(string), "", 1)
staticPath := strings.Replace(delPrefix, "{language}", lang, 1)
newFile := fmt.Sprintf("%s%s", dir, staticPath)
err = file.CopyUploadFile(body.UploadPath, newFile)
if err != nil {