I've got an application that accepts PDF file uploads and stores them in a BLOB column in MySQL. Another application pulls data from the database and sends it to the browser. When the database is queried the BLOB column is written to a file in a public HTML directory and a link is sent to the browser.

My problem is that when users click on the link the Acrobat plug-in loads and then errors out with "Object Label Badly Formatted". If I move the PDF to the directory myself then it loads correctly in the browsers. ls -Fla on the directory shows that the two files (uploaded through the application and copied in with Samba) have sizes that differ by 8 bytes (the uploaded file is larger).

Any ideas of where to look? Here's the code that is accepting the upload:
my $pdf_name = $cgi_query->param('event_pdf'); my $pdf = 'EventPDF'; if ($pdf_name){ #A file (supposedly a PDF) has been sent in the + post data. Load it into $pdf for storage in events table binmode($pdf_name); while (<$pdf_name>){ $pdf .= $_; } $pdf = $db->quote($pdf); } my $mime_type; #(Not very robust) type checking for uploaded file. This is depen +dent on the browser behaving $mime_type = $cgi_query->uploadInfo($pdf_name)->{'Content-Type'} i +f $pdf_name; if ($mime_type){ return $self->display_error("Attached file is not a PDF\n") un +less $mime_type eq 'application/pdf'; }


Thanks!
--TWH

In reply to Object Label Badly Formatted by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.