Content-Disposition Filename
Here we'll give an example of manipulation Content-Disposition
based on file type or extension. For the sake of the example, we've selected a few extensions that we want to append with Content-Disposition
and provide the file name to it. Any file that doesn’t meet this condition will be defined as Noname.
NginX configuration block
location / { set $file_name "noname"; if ($request_uri ~ \.(pdf|doc?|rtf|txt)$) { set $file_name $baseuri; } add_header Content-Disposition 'attachment; filename="$file_name"'; … }
CURL to a file from the above list (pdf, doc, Docx, RTF, txt)
curl -I cdn.domain.com/example.pdf HTTP/1.1 200 OK Date: Sat, 07 Mar 2015 23:20:30 GMT Content-Type: application/pdf Content-Length: 2546858 Connection: keep-alive Cache-Control: max-age=604800 Accept-Ranges: bytes Server: NetDNA-cache/2.2 Content-Disposition: attachment; filename="example.pdf" Link:
CURL to a file, not in the above list (HTML)
curl -I cdn.domain.com/example.html HTTP/1.1 200 OK Date: Sat, 07 Mar 2015 23:20:31 GMT Content-Type: text/html;charset=UTF-8 Content-Length: 115293 Connection: keep-alive Cache-Control: private Accept-Ranges: bytes Server: NetDNA-cache/2.2 Content-Disposition: attachment; filename="noname" Link:
If you have any questions or experience any issues, please reach out to the Support Team, live chat and ticket support are available 24/7.