<div>
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.
</div><div>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.</div>
<div><div><br></div><div>Thanks!</div><div><br></div><div>-- </div><div>Rik Brown</div><div>http://www.rikbrown.co.uk</div><div><br></div></div>
<p style="color: #A0A0A8;">On Tuesday, 1 January 2013 at 18:17, Rik Brown wrote:</p>
<blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
<span><div><div>
<div>
Hi all,
</div><div><br></div><div>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?</div><div><br></div><div>I've done essentially this (simplified):</div><div><br></div><div>get '/some/route' => sub {</div><div> my $data = …get_image…;</div><div><br></div><div> header 'Content-Type' => 'image/jpeg';</div><div> return $data;</div><div>}</div><div><br></div><div>but this doesn't feel right and causes a broken output (appears to return only a few rows of pixels of the image). </div><div><br></div><div>Any tips?</div><div><br></div><div>Cheers</div>
<div><div><br></div><div>-- </div><div>Rik Brown</div><div><a href="http://www.rikbrown.co.uk">http://www.rikbrown.co.uk</a></div><div><br></div></div>
</div></div></span>
</blockquote>
<div>
<br>
</div>