forward arguments in upload module

Francis Daly francis at daoine.org
Sat Jun 11 12:46:48 MSD 2011


On Sat, Jun 11, 2011 at 12:40:36AM -0400, vetri wrote:

Hi there,

>>> i am sending query arguments in post operation which will be passed
>>> to backend server.

>   Thanks for the reply . i am not using form to upload files. i am using
> java client to send files to nginx via post operation.

So your java client is doing roughly the same thing as

curl -v -F f=@testfile -F submit=on -F k=v http://localhost:8085/zsupload

where "k=v" is your query arguments. Is that correct?

If you test using that tool, you'll be able to get the nginx config
right first; then you can change the client as needed to make sure it fits.

>>> i want to append one more key value pair to that query
>>> arguments to send into backend server(own key value will be taken from
>>> program)

If you want your program to send the extra k1=v1, then you just do it
the same way as you set the original k=v -- one more "-F k1=v1" in the
curl command line, and whatever you did in your java client for the
live solution.

If you want nginx to create the extra k1=v1 in between getting from the
client and sending to the backend, then you configure it as was suggested.

See below.

>  even though i tried what u said there is no notification at the backend
> .here is the config

>             # Set specified fields in request body
>             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";

Here, adding

	upload_set_form_field k1 v1;

will add that key/value pair to the request sent to the backend. You
can replace either of the k1/v1 strings with nginx variables that have
been set, just like the three previous lines.

That is for "nginx creates the extra k1/v1".

>             upload_pass_form_field "^submit$|^description$";

That setting is a regex which determines which of the keys sent by the
original client will be copied into the request sent to the backend.

So if you want the client to send k1/v1 and have it sent to the backend,
then you'll have to modify the above line to include matching "k1".

Good luck,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list