|
|
@@ -9,12 +9,11 @@ import (
|
|
|
sysutils "git.qianqiusoft.com/qianqiusoft/light-apiengine/utils"
|
|
|
"io"
|
|
|
"io/ioutil"
|
|
|
+ "mime"
|
|
|
"os"
|
|
|
"path"
|
|
|
- "time"
|
|
|
- "strings"
|
|
|
- "mime"
|
|
|
"strconv"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
// _Upload
|
|
|
@@ -52,11 +51,25 @@ func SysAttachment_Download(c *entitys.CtrlContext) {
|
|
|
|
|
|
filePath := "files/"+ attach.Id
|
|
|
|
|
|
- c.Ctx.Header("Content-Disposition", "attachment;filename=\""+sysutils.FormatForBrowse(c.Ctx.Request.UserAgent(), attach.Name)+"\"")
|
|
|
- c.Ctx.Header("Content-Type", strings.Replace(mime.TypeByExtension(attach.Ext), "charset=utf-8", "", -1))
|
|
|
- c.Ctx.Header("Content-Length", strconv.FormatInt(int64(attach.Size), 10))
|
|
|
+
|
|
|
+
|
|
|
+ c.Ctx.Writer.Header().Add("Content-Disposition", "attachment;filename=\""+sysutils.FormatForBrowse(c.Ctx.Request.UserAgent(), attach.Name)+"\"")
|
|
|
+ c.Ctx.Writer.Header().Add("Content-Type", mime.TypeByExtension(attach.Ext))
|
|
|
+ c.Ctx.Writer.Header().Add("Content-Length", strconv.FormatInt(int64(attach.Size), 10))
|
|
|
+ c.Ctx.Writer.Header().Add("Accept-Ranges", "bytes")
|
|
|
+
|
|
|
+ if !sysutils.Exists(filePath){
|
|
|
+ c.Ctx.Writer.WriteHeader(400)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println("---->", c.Ctx.Writer.Header().Get("Content-Disposition"))
|
|
|
+ fmt.Println("---->", c.Ctx.Writer.Header().Get("Content-Type"))
|
|
|
+ fmt.Println("---->", c.Ctx.Writer.Header().Get("Content-Length"))
|
|
|
+ fmt.Println("---->", c.Ctx.Writer.Header().Get("Accept-Ranges"))
|
|
|
+
|
|
|
c.Ctx.File(filePath)
|
|
|
- c.Ctx.Writer.WriteHeader(200)
|
|
|
+ /*attrId := c.Ctx.Query("id")
|
|
|
+ //c.Ctx.Writer.WriteHeader(200)
|
|
|
/*attrId := c.Ctx.Query("id")
|
|
|
|
|
|
filePath := fmt.Sprintf("files/%s", attrId)
|