用client_body_in_file_only上传nginx文件 [英] nginx file upload with client_body_in_file_only

查看:62
本文介绍了用client_body_in_file_only上传nginx文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

晚上好,我需要将静态内容上传到nginx服务器1.9(因此,上传模块不适用于该版本).我已阅读文章"Nginx直接文件上传而不将其通过后端" ,并按照说明进行操作.除了nginx数据目录中的文件名之外,所有内容对我而言都有效.文件名看起来像是"0000000001","0061565403",依此类推.如何保存具有正确名称的文件?这是我的Nginx位置配置:

Good evening, I need to upload static content to nginx server 1.9 (so upload module didn't work with this version). I've read the article "Nginx direct file upload without passing them through backend" and followed instructions step by step. Everything works for me, except file names at the nginx data directory. File names look like '0000000001', '0061565403' and so on. What should I do to save files with their correct names? Here is my nginx location config:

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标头来传递正确的名称(无论是什么名称),例如:

You can use HTTP header in the client to pass the correct name (whatever that is), e.g.:

Correct-Filename: my-correct-filename

并且由于您正在使用 proxy_pass_request_headers ,因此标题在后端可见,您可以在保存文件时使用它.但是,在使用标头时,文件名仅限于使用ASCII字符,请参见

And since you're using proxy_pass_request_headers on, the header is visible in the back end where you can use it when saving the file. However when using headers the filename is limited to using ASCII characters, see this answer.

这篇关于用client_body_in_file_only上传nginx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆