晚上好,
我需要将静态内容上传到 nginx 服务器 1.9(因此上传模块不适用于此版本)。我读过这篇文章“Nginx 直接文件上传,无需通过后端传递” https://coderwall.com/p/swgfvw/nginx-direct-file-upload-without-passing-them-through-backend并按照说明一步步进行。除了 nginx 数据目录中的文件名之外,一切都对我有用。文件名类似于“0000000001”、“0061565403”等。我应该怎样做才能以正确的名称保存文件?这是我的 nginx 位置配置:
location /upload {
limit_except POST { deny all; }
client_body_temp_path /data/;
client_body_in_file_only on;
client_body_buffer_size 128K;
client_max_body_size 50M;
proxy_pass_request_headers on;
proxy_set_header content-type "text/html";
proxy_set_body $request_body_file;
proxy_pass http://localhost:8080/
proxy_redirect off;}
您可以在客户端中使用 HTTP 标头来传递正确的名称(无论是什么),例如:
Correct-Filename: my-correct-filename
既然你正在使用proxy_pass_request_headers on
,标题在后端可见,您可以在保存文件时使用它。但是,当使用标头时,文件名仅限于使用 ASCII 字符,请参阅这个答案 https://stackoverflow.com/questions/4400678/what-character-encoding-should-i-use-for-a-http-header/4410331#4410331.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)