trying to extract blob as file... is corrupted

T

Tomasz Chmielewski

I have a database which has a lot of files saved as blobs (some "fancy" CMS system).

I would like to save them as files.

I saved them as files using such a query (for each blob):

my $sql = $db->prepare("SELECT blob_data FROM tx_drblob_content WHERE uid = (?)");
$sql->execute($uid); # $uid is ID of the blob in the database
my $blob = $sql->fetchrow_array;
open BLOBFILE, ">$datadir/$uid" or die "Cannot open $!";
print BLOBFILE $blob;
close BLOBFILE;

Unfortunately, the files (PDF, ZIP etc.) are corrupted.

I "uploaded" a text file to the database using system's web interface, then fetched it with the above perl code.

Here are some example differences (- denotes original file; + denotes the file fetched with perl):

-# From ``Assigned Numbers'':
+# From ``Assigned Numbers\'\':


So we can see that the file has \ appended in front of each '.

Which could be because the CMS system stores the files as such, or perhaps I should fetch/save the files differently?

Does anyone have some obvious thoughts on why I see \ appended before certain characters?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top