我有一些.csv文件是直接从文件系统通过 Nginx 提供的。目前它看起来像这样::
location ~ /static/csv_exports/ {
add_header Content-Type text/csv;
}
Run Code Online (Sandbox Code Playgroud)
由于某种原因,我必须这样做,因为否则它将被用作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
Run Code Online (Sandbox Code Playgroud)
看!它有两个“Content-Type”标头。在浏览器中打开它会自动打开 Open Office,它工作得很好,但我怀疑我做得不对。
location ~ /static/csv_exports/ {
- add_header Content-Type text/csv;
+ types {text/csv csv;}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3661 次 |
| 最近记录: |