[Catalyst] PDF upload problems (prob OT)?

Dr. Jennifer Nussbaum bg271828 at yahoo.com
Thu Nov 6 16:04:08 GMT 2008

Hi. Last month i had some questions about uploading PDF's in a Catalyst app, and J. Shirley gave me some helpful advice. I got it working, or so i thought, and then put the project aside as the users werent ready for it.

I just got back to it and i see that theres some kind of problem. The PDF's when displayed in my app are mangled; they are visible but there are display problems with them (parts cut off, or the image shifted). I dont know if it was like this originally and i just didnt notice, or if something has changed, but i dont know where to look and would be greatful for a push in the right direction.

Im storing them in a MySQL database, with the PDF field a MEDIUMBLOB so large enough for a 16M file.

My upload code is basically:

my $upload = $c->request->upload('document');
my $document = $c->model->create({ document => $upload->slurp,
                                   type => $upload->type,
                                   filename => $upload->basename});

And then my display code is:

# $document is already grabbed from the database
$c->res->output($document); # overloaded to stringify to $document->document
$c->res->headers->header('Content-Disposition' => 'attachment; filename=".$document->filename);

(As another question, is this the right way to get the filename to the browser? The docs for HTTP::Headers didnt say anything about this.)

Theres a length difference when i download. A test file i uploaded is 165681 bytes, but when i upload and save it to the database, and then display the file from my app and save it, its 165685 bytes--four more.

What should i be looking at to try to figure this out?




More information about the Catalyst mailing list