[dancer-users] Outputting binary data

Rik Brown rik at rikbrown.co.uk
Tue Jan 1 18:17:28 GMT 2013


Hi all,  

If I've got a scalar $data containing some binary data (a JPG image read using read_file($file, binmode => ':raw' ), how can I cause one of my routes to output it?

I've done essentially this (simplified):

get '/some/route' => sub {
  my $data = …get_image…;

  header 'Content-Type' => 'image/jpeg';
  return $data;
}

but this doesn't feel right and causes a broken output (appears to return only a few rows of pixels of the image).     

Any tips?

Cheers  

--  
Rik Brown
http://www.rikbrown.co.uk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20130101/fb33973b/attachment.htm>


More information about the dancer-users mailing list