views:

356

answers:

1

I want to create a new object using Class::DBI. One of the fields of this object is a BLOB type. I have a filehandle I want to use for this data, but apparently, just doing this doesn't work:

my $item = My::Class::DBI::Class->insert({
        foo       => $bar,
        biz       => $baz,
        blob         => $my_filehandle
        });

Is there some trick I am missing?

Thanks!

+4  A: 

You have to read out the filehandle, and insert that.

my $blob = do {local $/; <$my_filehandle>};
my $item = My::Class::DBI::Class->insert({
        foo       => $bar,
        biz       => $baz,
        blob         => $blob,
        });
Leon Timmermans