1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-06-17 22:37:33 +02:00

Add attachment option for Content-Disposition header (#887)

* Add attachment option for Content-Disposition header

Signed-off-by: Valentin Kiselev <mrexox@evilmartians.com>

* Add documentation to attachment option

Signed-off-by: Valentin Kiselev <mrexox@evilmartians.com>

* Add default attachment option value

Signed-off-by: Valentin Kiselev <mrexox@evilmartians.com>

* fix: Add default value to docs

Signed-off-by: Valentin Kiselev <mrexox@evilmartians.com>

* fix: Rename option attachment to return_attachment, add ENV-configuration

Signed-off-by: Valentin Kiselev <mrexox@evilmartians.com>
This commit is contained in:
Valentine Kiselev
2022-06-06 11:53:09 +03:00
committed by GitHub
parent e06dce6a49
commit 23d0807e46
6 changed files with 54 additions and 21 deletions

View File

@ -86,9 +86,9 @@ func setVary(rw http.ResponseWriter) {
func respondWithImage(reqID string, r *http.Request, rw http.ResponseWriter, statusCode int, resultData *imagedata.ImageData, po *options.ProcessingOptions, originURL string, originData *imagedata.ImageData) {
var contentDisposition string
if len(po.Filename) > 0 {
contentDisposition = resultData.Type.ContentDisposition(po.Filename)
contentDisposition = resultData.Type.ContentDisposition(po.Filename, po.ReturnAttachment)
} else {
contentDisposition = resultData.Type.ContentDispositionFromURL(originURL)
contentDisposition = resultData.Type.ContentDispositionFromURL(originURL, po.ReturnAttachment)
}
rw.Header().Set("Content-Type", resultData.Type.Mime())