Try this. Just create a dhandler.mp in the folder where the generated
images would be located. You’ll need to change the MIME Type depending on
the type of image you’re generating.

#################################################################################
  Application    : Your application name#   Filename       :
/images/dhandler.mp#   Purpose        : Generate dynamic file#   Last
Author    : $Author: $#   Last Date      : $Date: $#   Last Version
: $Revision: 
$################################################################################
use Poet qw( $log );

method handle() {
    my $arg = $m->request_args();

    # Grab the filename from the path
    # ie. /images/generated.jpg returns 'generated.jpg'
    my $filename = $m->path_info();

    # Generate some data
    # my $image data = ...
    # ...

    $m->clear_buffer();
    $m->res->content_type( 'image/jpeg' );
    $m->res->header( 'Content-Disposition' => qq{attachment;
filename="$filename"} );
    $m->print( $image_data );
    $m->abort();
}

I hope this helps.
​

On 6 October 2014 10:55, Andrew Kirkland <djand...@gmail.com> wrote:

> I recently did this for CSV files. I'll send you the code when I get back
> to the office :)
> On 06/10/2014 10:54 AM, <b...@blackowl.org> wrote:
>
>> Dear All,
>>
>> I currently generate an image dynamically and would
>> like to send it from within a component to the client.
>>
>> I found ways to deal with this issue with Html::Mason,
>> (clearing the buffer, setting the content type, etc)
>> but I'd like to achieve this with Mason+Poet.
>>
>> What would be the proper way proceed?
>>
>> Thank you,
>> =BO
>>
>>
>> ------------------------------------------------------------------------------
>> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
>> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
>> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
>> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Mason-users mailing list
>> Mason-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/mason-users
>>
>


-- 

View Andrew's Linkedin profile <http://au.linkedin.com/in/djandiek>
[image: http://au.linkedin.com/in/djandiek]
<http://au.linkedin.com/in/djandiek>
------------------------------------------------------------------------------
Slashdot TV.  Videos for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to