2

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!

pkaeding
  • 36,513
  • 30
  • 103
  • 141

1 Answers1

5

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
  • 30,029
  • 2
  • 61
  • 110