[Catalyst] Looking at upload size/type before it is uploaded?
Tomas Doran
bobtfish at bobtfish.net
Sat Jul 11 12:56:20 GMT 2009
On 10 Jul 2009, at 16:36, A Murka wrote:
> What's the recommended way to validate file upload's size and type
> (either filename or MIME) before downloading it into the temp
> directory? I don't want the user to be able to upload a 200 MB file in
> its entirety before having the controller reject it for being too big.
You're looking for http://search.cpan.org/~flora/Catalyst-
Runtime-5.80007/lib/Catalyst.pm#ON-DEMAND_PARSER
Set that, and the body of the request will only be read when you
access it. So you can check the content-length (and other headers)
and reject the request before the rest of the content arrives...
Cheers
t0m
More information about the Catalyst
mailing list