Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx file upload with client_body_in_file_only

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;}
like image 498
VoV4a Avatar asked Oct 31 '22 06:10

VoV4a


1 Answers

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

Correct-Filename: my-correct-filename

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.

like image 184
Eino Malinen Avatar answered Nov 22 '22 12:11

Eino Malinen