mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-10 20:22:31 +02:00
Add Content-Disposition filename customization
This commit is contained in:
@@ -46,10 +46,17 @@ func initProcessingHandler() {
|
||||
func respondWithImage(ctx context.Context, reqID string, r *http.Request, rw http.ResponseWriter, data []byte) {
|
||||
po := getProcessingOptions(ctx)
|
||||
|
||||
var contentDisposition string
|
||||
if len(po.Filename) > 0 {
|
||||
contentDisposition = po.Format.ContentDisposition(po.Filename)
|
||||
} else {
|
||||
contentDisposition = po.Format.ContentDispositionFromURL(getImageURL(ctx))
|
||||
}
|
||||
|
||||
rw.Header().Set("Expires", time.Now().Add(time.Second*time.Duration(conf.TTL)).Format(http.TimeFormat))
|
||||
rw.Header().Set("Cache-Control", fmt.Sprintf("max-age=%d, public", conf.TTL))
|
||||
rw.Header().Set("Content-Type", po.Format.Mime())
|
||||
rw.Header().Set("Content-Disposition", po.Format.ContentDisposition(getImageURL(ctx)))
|
||||
rw.Header().Set("Content-Disposition", contentDisposition)
|
||||
|
||||
if len(headerVaryValue) > 0 {
|
||||
rw.Header().Set("Vary", headerVaryValue)
|
||||
|
Reference in New Issue
Block a user