merge: 合并OMC分支

This commit is contained in:
TsMask
2024-07-10 14:18:48 +08:00
parent 17c0011c6b
commit 625ed57a50
260 changed files with 9167 additions and 14857 deletions

View File

@@ -43,13 +43,6 @@ func (s *FileController) Download(c *gin.Context) {
return
}
routerPath := string(decodedBytes)
// 地址文件名截取
fileName := routerPath[strings.LastIndex(routerPath, "/")+1:]
// 响应头
c.Writer.Header().Set("Content-Disposition", `attachment; filename="`+url.QueryEscape(fileName)+`"`)
c.Writer.Header().Set("Accept-Ranges", "bytes")
c.Writer.Header().Set("Content-Type", "application/octet-stream")
// 断点续传
headerRange := c.GetHeader("Range")
@@ -58,6 +51,12 @@ func (s *FileController) Download(c *gin.Context) {
c.JSON(200, result.ErrMsg(err.Error()))
return
}
// 响应头
c.Writer.Header().Set("Content-Disposition", `attachment; filename="`+url.QueryEscape(filepath.Base(routerPath))+`"`)
c.Writer.Header().Set("Accept-Ranges", "bytes")
c.Writer.Header().Set("Content-Type", "application/octet-stream")
if headerRange != "" {
c.Writer.Header().Set("Content-Range", fmt.Sprint(resultMap["range"]))
c.Writer.Header().Set("Content-Length", fmt.Sprint(resultMap["chunkSize"]))
@@ -65,7 +64,6 @@ func (s *FileController) Download(c *gin.Context) {
} else {
c.Writer.Header().Set("Content-Length", fmt.Sprint(resultMap["fileSize"]))
c.Status(200)
}
c.Writer.Write(resultMap["data"].([]byte))
}
@@ -222,7 +220,7 @@ func (s *CommontController) TransferStaticFile(c *gin.Context) {
delPrefix := strings.Replace(body.StaticPath, static["prefix"].(string), "", 1)
staticPath := strings.Replace(delPrefix, "{language}", lang, 1)
newFile := fmt.Sprintf("%s%s", dir, staticPath)
newFile := filepath.ToSlash(fmt.Sprintf("%s%s", dir, staticPath))
err = file.CopyUploadFile(body.UploadPath, newFile)
if err != nil {