[Catalyst] internal redirect

Roberto Henríquez roberto at freekeylabs.com
Wed Apr 11 16:31:18 GMT 2007


Adeola Awoyemi escribió:
> Hi all,
>
> Is there a way to do an internal redirect in Catalyst?
>
> In my application I'm generating images on the fly and want to 
> redirect to the image if creation succeeds.
>
> For instance:
>
>     $image = Imager->new()
>     $image->read( file => $src_file );
>     $new_img = $image->copy->scale( xpixels => 32, ypixels => 32 );
>     if ( $new_img->write( file => $new_filename ) ) {
>         # do internal redirect to new file here
>     }
>
> I tried using "$c->response->redirect( $new_filepath )" but that 
> issues a 302 "Temporarily Moved" status. But what I actually want is a 
> way to do the redirect outside of the response chain.
>
> I hope this is clear?!
>
Hi,

another option would be to store the generated files somewhere under the 
control of the Static::Simple plugin, and then redirect the user there:

$c->res->redirect( $c->uri_for('/static/', 'path/to/my/file') );

See Catalyst::Plugin::Static::Simple documentation for details on how to 
define what directories it takes care of.

--R




More information about the Catalyst mailing list