|
|
@@ -13,7 +13,10 @@ import (
|
|
|
"os"
|
|
|
"path"
|
|
|
"strconv"
|
|
|
+<<<<<<< HEAD
|
|
|
"strings"
|
|
|
+=======
|
|
|
+>>>>>>> 06105bace411eb44ed1c3037d5d722e4e881cc2a
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
@@ -52,11 +55,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)
|