[dancer-users] Outputting binary data
Rik Brown
rik at rikbrown.co.uk
Tue Jan 1 18:20:02 GMT 2013
I'll follow myself up here almost immediately by saying I fixed this - it was my own fault reading the data in the first place.
However, if anyone has any thoughts whether what I've done conforms to any "Right Way" of outputting binary data via Dancer, please let me know.
Thanks!
--
Rik Brown
http://www.rikbrown.co.uk
On Tuesday, 1 January 2013 at 18:17, Rik Brown wrote:
> 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/9ee0398f/attachment.htm>
More information about the dancer-users
mailing list