我有一些.csv
个文件,我直接从文件系统通过Nginx提供服务。
它目前看起来像这样::
location ~ /static/csv_exports/ {
add_header Content-Type text/csv;
}
出于某种原因,我必须这样做,因为否则它将被视为text/plain
。这是我卷曲时得到的结果:
$ curl -v http://localhost/static/csv_exports/20110322_172651.csv >> /dev/null
...
< HTTP/1.1 200 OK
< Server: nginx/0.7.67
< Date: Tue, 22 Mar 2011 17:32:07 GMT
< Content-Type: text/plain
< Content-Length: 356623
< Last-Modified: Tue, 22 Mar 2011 17:26:52 GMT
< Connection: keep-alive
< Cache-Control: public
< Content-Type: text/csv
< Accept-Ranges: bytes
请参阅!它有两个“Content-Type”标题。在浏览器中打开它会自动打开Open Office,它工作正常,但我怀疑我做得不对。
答案 0 :(得分:4)
location ~ /static/csv_exports/ {
- add_header Content-Type text/csv;
+ types {text/csv csv;}
}