mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-04-30 16:28:23 -05:00
fix(attachments): use mime.FormatMediaType for Content-Disposition header
This commit is contained in:
@@ -19,6 +19,7 @@ package v1
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -210,9 +211,9 @@ func GetTaskAttachment(c *echo.Context) error {
|
|||||||
mimeToReturn = "application/octet-stream"
|
mimeToReturn = "application/octet-stream"
|
||||||
}
|
}
|
||||||
|
|
||||||
filename := strings.ReplaceAll(taskAttachment.File.Name, `"`, `\"`)
|
c.Response().Header().Set("Content-Disposition", mime.FormatMediaType("attachment", map[string]string{
|
||||||
|
"filename": taskAttachment.File.Name,
|
||||||
c.Response().Header().Set("Content-Disposition", "attachment; filename=\""+filename+"\"")
|
}))
|
||||||
c.Response().Header().Set("Content-Type", mimeToReturn)
|
c.Response().Header().Set("Content-Type", mimeToReturn)
|
||||||
c.Response().Header().Set("Content-Length", strconv.FormatUint(taskAttachment.File.Size, 10))
|
c.Response().Header().Set("Content-Length", strconv.FormatUint(taskAttachment.File.Size, 10))
|
||||||
c.Response().Header().Set("Last-Modified", taskAttachment.File.Created.UTC().Format(http.TimeFormat))
|
c.Response().Header().Set("Last-Modified", taskAttachment.File.Created.UTC().Format(http.TimeFormat))
|
||||||
|
|||||||
Reference in New Issue
Block a user