no message

master
a7458969 2020-05-11 16:28:25 +08:00
parent 290049bb38
commit a050f8928b
2 changed files with 19 additions and 4 deletions

View File

@ -97,6 +97,24 @@ func (this *FileController) FileType(c *gin.Context) {
}
func (this *FileController) DownloadFile(c *gin.Context) {
resp := RespBase{Msg:"FAIL",Status: 211}
filename := c.Query("filename")
file,e := os.Open( "files//" +filename)
if nil != e{
log.Print(e.Error())
c.JSON(200,resp)
return
}
bytes,e :=ioutil.ReadAll(file)
if nil != e{
log.Print(e.Error())
c.JSON(200,resp)
return
}
c.Header("X-Content-Type-Options", "nosniff")
c.Header("Content-Disposition",
"/files/" + filename)
c.Writer.Write(bytes)
}

View File

@ -3,7 +3,6 @@ package utils
import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
@ -32,18 +31,16 @@ type FileDesc struct {
Name string `json:"name"`
}
func GetPathFileName(pathname string,desc *FileDesc) (error) {
log.Print("call once")
desc.Name = pathname
desc.Child = make([]FileDesc,0)
desc.Types = 1 // 1 means fileholder
rd, err := ioutil.ReadDir(pathname)
for _, fi := range rd {
log.Print(fi.Name())
if fi.IsDir() {
childdir := new (FileDesc)
childdir.Types = 1
childdir.Name = fi.Name()
GetPathFileName(pathname + "\\"+ fi.Name() + "\\",childdir)
GetPathFileName(pathname + fi.Name() + "\\",childdir)
desc.Child = append(desc.Child,*childdir)
} else {
childdir := new (FileDesc)