我有一些.csv
文件,我直接从文件系统通过Nginx提供。 目前看起来像这样::
location ~ /static/csv_exports/ { add_header Content-Type text/csv; }
出于某种原因,我必须这样做,否则将作为text/plain
。 这是我在curl时得到的:
$ 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,它工作的很好,但我怀疑我没有做到这一点。
location ~ /static/csv_exports/ { - add_header Content-Type text/csv; + types {text/csv csv;} }