Welcome! Log In Create A New Profile

Advanced

Взаимодействие http_perl_module и http_upload_module

erd
July 06, 2012 04:00AM
Здравствуйте.

Пробовал реализовать загрузку файлов с использованием http_perl_module и http_upload_module. Непосредственно загрузка и сохранение файла проходят успешно, однако в запросе к @upload не передаются абсолютно никакие параметры, даже тот, что был задан через upload_pass_form_field.

Самостоятельно ошибку или причину недопонимания найти не получается, поэтому прошу помощи здесь.

nginx version: nginx/1.3.2
configure arguments: --prefix=/usr/local/etc/nginx --with-cc-opt='-I /usr/local/include' --with-ld-opt='-L /usr/local/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin/nginx --pid-path=/var/run/nginx.pid --error-log-path=/var/log/nginx-error.log --user=www --group=www --with-file-aio --with-ipv6 --http-client-body-temp-path=/var/tmp/nginx/client_body_temp --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi_temp --http-proxy-temp-path=/var/tmp/nginx/proxy_temp --http-scgi-temp-path=/var/tmp/nginx/scgi_temp --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi_temp --http-log-path=/var/log/nginx-access.log --add-module=/usr/ports/www/nginx-devel/work/ngx_cache_purge-1.6 --with-http_image_filter_module --with-http_perl_module --with-http_stub_status_module --with-http_sub_module --add-module=/usr/ports/www/nginx-devel/work/nginx_upload_module-2.2.0 --add-module=/usr/ports/www/nginx-devel/work/masterzen-nginx-upload-progress-module-a788dea --add-module=/usr/ports/www/nginx-devel/work/chaoslawful-lua-nginx-module-3b1e9aa --with-pcre --add-module=/usr/ports/www/nginx-devel/work/simpl-ngx_devel_kit-bc97eea --add-module=/usr/ports/www/nginx-devel/work/calio-iconv-nginx-module-abdac17

#настройки nginx

server {
client_header_buffer_size 4k;
...
location /u {
root /home/webl/www/node1;
error_page 403 = 404;
}
location @upload {
perl WebLab::upl;
}
location =/upload {
client_max_body_size 15m;

upload_pass @upload;

upload_store /home/webl/www/node1/u;
upload_store_access user:r;

# upload_set_form_field $upload_field_name.name "$upload_file_name";
# upload_set_form_field $upload_field_name.content_type "$upload_content_type";
# upload_set_form_field $upload_field_name.path "$upload_tmp_path";

# upload_aggregate_form_field "$upload_field_name.md5" "$upload_file_md5";
# upload_aggregate_form_field "$upload_field_name.size" "$upload_file_size";

upload_set_form_field "${upload_field_name}_name" $upload_file_name;
upload_set_form_field "${upload_field_name}_content_type" $upload_content_type;
upload_set_form_field "${upload_field_name}_path" $upload_tmp_path;

upload_aggregate_form_field "${upload_field_name}_md5" $upload_file_md5;
upload_aggregate_form_field "${upload_field_name}_size" $upload_file_size;

upload_pass_form_field "^test$";

upload_cleanup 400-404 499 500-505;
}
}

#обработчик WebLab::upl;

package WebLab;

sub upl
{
no strict;
no warnings;
shift->has_request_body(sub{
my$r = shift;
$r->send_http_header("text/plain");
$r->print("request_body: \"", $r->request_body, "\"\n");
$r->print("request_body_file: \"", $r->request_body_file, "\"\n");
});
}

#пример запроса на /upload

POST /upload HTTP/1.1
Host: node1.webl
Connection: keep-alive
...
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryJ0GtAjmfwCLxtzFL

------WebKitFormBoundaryJ0GtAjmfwCLxtzFL
Content-Disposition: form-data; name="file"; filename="image.jpg"
Content-Type: image/jpeg


------WebKitFormBoundaryJ0GtAjmfwCLxtzFL
Content-Disposition: form-data; name="test"

val
------WebKitFormBoundaryJ0GtAjmfwCLxtzFL--

#ответ от сервера

request_body: "------WebKitFormBoundaryJ0GtAjmfwCLxtzFL"
request_body_file: ""
Subject Author Posted

Взаимодействие http_perl_module и http_upload_module

erd July 06, 2012 04:00AM

Re: Взаимодействие http perl module и http upload module

Bdfy July 06, 2012 05:44AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 55
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready