[Catalyst] Simple blob upload example?

J. Shirley jshirley at gmail.com
Fri Sep 19 16:52:53 BST 2008


On Fri, Sep 19, 2008 at 7:40 AM, Dr. Jennifer Nussbaum
<bg271828 at yahoo.com> wrote:
> Hi,
>
> Im about to start an app where i'll need to upload PDFs from a user and store them in my database. Is there any quick example that might show
> how to do this? I browsed through the wiki and didnt see anything. I know its simple but ive never done this before.
>
> Thanks!
>
> Jen
>

To divert this a bit, are you -really- sure you want to store them in
a database?  Storing large files in a database is not going to be
ideal, as you'll lose abilities to replicate the files in a separate
policy from you DB, etc.

I really like MogileFS for storing files, and it really is easy enough
to setup on a single host and get going... then from there, it's as
simple as:

$mogilefs->store_file( $key, $class, $upload->tempfile );

But to answer your question, the uploads are this object:
http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7014/lib/Catalyst/Request/Upload.pm

You can then just do $db_record->contents( $upload->slurp );

-J



More information about the Catalyst mailing list