How do you insert binary data into a BLOB column with Class::DBI?
Question
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!
Solution
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,
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow