extend the upload module

Francis Daly francis at daoine.org
Mon Apr 23 18:12:28 UTC 2012


On Mon, Apr 23, 2012 at 09:52:04AM -0400, JCR wrote:

Hi there,

> I am using the /nginx_upload_module-2.2.0 with nginx 1.0.15
> with great success
> 
> I would like to extend it in two ways:

I suspect that these extensions would be out of scope for this module,
which seems to be more about making it easier to write your own form
handler.

That said, I'm sure no-one's going to stop you from coding.

> (1)
> Each HTTP POST request to the module contains a username and a password
> field and I would like to make some checks on those values as early as
> possible and possibly reject the request even before the file is
> uploaded.

If you used http basic authentication, the effect of this could come
for free. But you don't.

Fundamentally, what you seem to want is for the handler to read a part
of the POST request body and then decide whether to respond and close
the connection, or accept the rest of the request body.

I'm not sure how you'd go about that.

> (2)
> I would like to save the file in a directory which depends on the file
> name and using the original file name instead of the current 10-digit
> 000... filename

That one is probably better handled in your own form handler -- you can
be given the original suggested filename and the 10-digit filename, and
do a "mv" of one to the other, handling duplicates and evil filenames as
you see fit. No need to hard-code the handling within the module.

You probably will want to make sure that "upload_store" is on the same
filesystem as you wish the files to end up on.

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list