I'm writing a file upload handler Catalyst. I'm trying to restrict the maximum file size. To do this I've made a Plugin (based on the answer here). Here is the code where I check for the file size:
before 'prepare_body' => sub {
my $c = shift;
my $req = $c->request;
my $length = $req->headers->{"content-length"};
if ($length > 10000)
{
$c->stash->{errors} = "File upload error";
# how do I abort the upload?
}
};
This correctly detects files that are too big, but I can't for the life of me figure out how to abort the upload. Ideally, it should also reach the controller/action. Can anyone give me a pointer? Thanks a lot.