Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: File download from BLOB

by bluescreen (Friar)
on Mar 25, 2011 at 15:46 UTC ( [id://895523]=note: print w/replies, xml ) Need Help??


in reply to File download from BLOB

You're almost there. The BLOB out of mysql is an scalar with binary content, then after setting the proper headers like you doing on the Apache2's example. you have to print the contents of the blob you get from the DB

Replies are listed 'Best First'.
Re^2: File download from BLOB
by wolfie7873 (Novice) on Mar 25, 2011 at 15:57 UTC
    OK, getting there: Here's what I've got that provides the proper download dialog:
    $r->content_type('application/x-download'); $r->err_headers_out->add('Content-disposition' => ("attachment; filena +me=$filename")); my ($st,$sth) = (); $st = "SELECT bin_data FROM forms WHERE filename = '$filename'"; $sth = $dbh->prepare($st) or die "Prepare Failed! " . $st . $dbh->errs +tr(); $sth->execute() or die "Execute Failed! " . $st . $sth->errstr(); my $filedata = $sth->fetchrow(); $sth->finish(); $m->print($filedata); return;
    But the PDF is un-openable upon return. Is that a transmission problem, or a db problem or what?
      But the PDF is un-openable

      You haven't mentioned what platform you're on, so this is just a guess...

      Often, the issue rendering files un-openable is inadvertently having applied linefeed translations to binary formats (such as PDF).  So try using binmode on the file handle $m before writing the blob to it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://895523]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-25 14:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found