ПРОЕКТЫ 


  АРХИВ 


Apache-Talk @lexa.ru 

Inet-Admins @info.east.ru 

Filmscanners @halftone.co.uk 

Security-alerts @yandex-team.ru 

nginx-ru @sysoev.ru 


  СТАТЬИ 


  ПЕРСОНАЛЬНОЕ 


  ПРОГРАММЫ 



ПИШИТЕ
ПИСЬМА












     АРХИВ :: nginx-ru
Nginx-ru mailing list archive (nginx-ru@sysoev.ru)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • To: nginx-ru <nginx-ru@xxxxxxxxx>
  • Subject: Взаимодействие http perl module и http upload module
  • From: Ivan <bdfy@xxxxxxx>
  • Date: Fri, 06 Jul 2012 19:06:38 +0400
  • Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail; h=Content-Type:Message-ID:Reply-To:Date:Mime-Version:Subject:To:From; bh=06Ps2hoDBaljzOg5KyYSBrE2aFMRecC1zEZDeQ9tBp8=; b=bgqXsRYH/0sCYROxvIQAaQLzdFKOpb9X9RxckIzllA9dXndCIY/VjkNNeAeHg4GXrki5vhSHZnUuWpqdcYufGTLJWhSkaOlgYE7ZzNAeq5Fn9DB2Ps2048yTsgaMr3lK;


прочитайте вот это:
http://forum.nginx.org/read.php?21,216148,216148

и используете следующую конструкцию:

server {

    listen 3000;

    location / {
    default_type text/html;
    perl uploader::handler;
    }

}




   location @uploadhandler {
        proxy_pass http://localhost:3000;
    }

   upload_pass   @uploadhandler;





Fri, 6 Jul 2012 04:00:18 -0400 (EDT) от "erd" <nginx-forum@xxxxxxxx>:
Здравствуйте.

Пробовал реализовать загрузку файлов с
использованием 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: ""

Posted at Nginx Forum: http://forum.nginx.org/read.php?21,228322,228322#msg-228322

_______________________________________________
nginx-ru mailing list
nginx-ru@xxxxxxxxx
http://mailman.nginx.org/mailman/listinfo/nginx-ru



_______________________________________________
nginx-ru mailing list
nginx-ru@xxxxxxxxx
http://mailman.nginx.org/mailman/listinfo/nginx-ru


 




Copyright © Lexa Software, 1996-2009.