[Catalyst] How to do REST without deserializing uploaded files (PUT)
Bruce McKenzie
brucem at dynamicrange.com
Wed Apr 1 05:03:15 BST 2009
I have a controller subclassed from Catalyst::Controller::REST.
Most of my methods are happily ActionClass('REST')'d, but I have one
where I want a file to be uploaded and NOT
deserialized. Even if I did not include the ActionClass attribute, I
would get a complaint about no deserialization method for the upload.
I couldn't figure out how to do it, so I backed out the RESTness from
the controller and implemented a "straight" put method:
sub xxx :Local :Args(0) {
my ( $self, $c ) = @_;
return if $c->request->method ne 'PUT';
my $filecontents = '';
my ($fh) = $c->request->body;
while ( my $line = <$fh> )
{
$filecontents .= $line;
}
.... do something with it ...
$c->response->status('202');
$c->response->body( "stuff accepted" );
}
Is there a way to declare some paths as NOT subject to
deserialization? The reason I ask is that I want it for most
everything...just not for a few paths.
(Incidentally, am I doing the right thing to get the file contents? It
seems to work and I can't find any other doc/pointers)
FWIW I was using curl to test it:
curl -T somefile http://localhost:3000/demo/xxx
Thanks very much!
Bruce
---
Bruce McKenzie
brucem at dynamicrange.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090331/e6f7d21d/attachment.htm
More information about the Catalyst
mailing list