# Using http\_upload\_module with http\_perl\_module

**URL:** <https://www.ruby-forum.com/t/using-http-upload-module-with-http-perl-module/221326>\
**Category:** NGINX\
**Created:** [July 9, 2012, 10:26am UTC](https://www.ruby-forum.com/t/using-http-upload-module-with-http-perl-module/221326 "2012-07-09T10:26:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [July 9, 2012, 10:26am UTC](https://www.ruby-forum.com/t/using-http-upload-module-with-http-perl-module/221326/1 "2012-07-09T10:26:26Z")

</div>

Hi, everyone.

I am trying to implement upload using http\_upload\_module with  
http\_perl\_module. But I am stuck at moment when upload\_module should  
send obtained information about successfuly uploaded file to the  
internal redirect @upload. @upload location perl handler invoke, but it  
never recieved any of arguments, even those, which defined from  
upload\_pass\_form\_field.

I mean, I have received temporary files at “/u” location, and I have  
seen WebLab::upl handler result, but without any POST arguments inside.

I probably doing something wrong, but I do not know what. And sorry for  
my English.

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 config

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 handler

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”);  
});  
}

#request to /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–

#Server response (from @upload)

request\_body: “------WebKitFormBoundaryJ0GtAjmfwCLxtzFL”  
request\_body\_file: “”

Posted at Nginx Forum:

> **[Using http\_upload\_module with http\_perl\_module](https://forum.nginx.org/read.php?2,228424,228424#msg-228424)**
>
> Hi, everyone. I am trying to implement upload using http\_upload\_module with http\_perl\_module. But I am stuck at moment when upload\_module should send obtained information about successfuly uploaded file to the internal redirect @upload. @upload...

---

<div class="post-metadata">

**Author:** ![erd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f07891/32.png) [@erd](https://www.ruby-forum.com/u/erd)\
**Post date:** [July 9, 2012, 11:26am UTC](https://www.ruby-forum.com/t/using-http-upload-module-with-http-perl-module/221326/2 "2012-07-09T11:26:13Z")

</div>

> **[Взаимодействие http perl module и http upload module](https://forum.nginx.org/read.php?21,228336)**
>
> прочитайте вот это: http://forum.nginx.org/read.php?21,216148,216148 и используете следующую конструкцию: server {     listen 3000;     location / {     default\_type text/html;

Posted at Nginx Forum:

> **[Re: Using http\_upload\_module with http\_perl\_module](https://forum.nginx.org/read.php?2,228424,228430#msg-228430)**
>
> Hi, everyone. I am trying to implement upload using http\_upload\_module with http\_perl\_module. But I am stuck at moment when upload\_module should send obtained information about successfuly uploaded file to the internal redirect @upload. @upload...
