How to force file download in the browser, nginx server

前端 未结 4 1420
误落风尘
误落风尘 2021-01-04 05:38

I currently have 2 image locations and they may the formats (jpg,jpeg,png,gif)

i.domain.com/simage.jpg thumbnail
i.domain.com/image.jpg high quality
i.domain         


        
4条回答
  •  误落风尘
    2021-01-04 06:28

    You just need to return HTTP header Content-disposition:

    location ~* /orig/(.+\.jpg)$ {
        add_header Content-disposition "attachment; filename=$1";
    }
    

提交回复
热议问题