0

the question I have is: How do I convert blob(I think?) back to it's actual filetype? I'm honestly not sure where to ask this so I figured I'd start here. Sorry in advance if it's not. At work we have this older system. I say older because it was put in place before I was got here, not because it's actually old. It stores documents that we process into a mssql database.

The file types are pdf, excel, msg, and probably more.

An example row from the DB.

id              7
docid           7
filename        Medical benefits and rates.pdf
filesize        50669
filetype        pdf
path            NULL
image           2030206F626A0D0A3C3C202F54797065202F50616765202F506172...
created         2009-06-02 18:45:15.483
modified        NULL
isdeleted       0
session         NULL
isencrypted     0

Obviously I've shortened the image cell for security reasons. It's length is 43436. But given that information, is there anyway I can render this out to a user in it's original format? Be it a 3rd party program, or library. I'm fairly proficient with python, and web development.

WTFox
  • 171
  • 3
  • 9
  • You would presumably convert the hexadecimal `image` string to an array of bytes then write it to disk with the extension in `filetype`; [hexadecimal string to byte array in python](http://stackoverflow.com/questions/5649407/hexadecimal-string-to-byte-array-in-python) – Alex K. Nov 07 '14 at 15:49
  • @AlexK. I'm pretty close to getting this. Right now I'm dealing with pdf's. It's creating the file, sometimes the thumbnail appears correctly, I can even see how many pages are in the pdf but they're all blank. Adobe says 'Insufficient data for an image.' yet the end of the stream says 'startxref 751748 %%EOF'. – WTFox Nov 07 '14 at 16:46

0 Answers0