1

I have oracle db, with have column with blob files.

I getting data from table and i need to show data and blob in form.

Blob can be PDFs or images..

My question are how to know what is in blob,are that image , pdf or something third?

Thanx

Frink
  • 201
  • 3
  • 21
  • 1
    You should be storing the mime type next to your blob in the database. In the absence of that, give urlmon a try http://stackoverflow.com/questions/58510/using-net-how-can-you-find-the-mime-type-of-a-file-based-on-the-file-signature – Mike Hixson Jun 20 '14 at 06:18

1 Answers1

3

You'd have to store that information somewhere. Normally, if you're designing a table that stores multiple types of binary data, you'd have a blob column and then a separate varchar2 column that identifies the MIME type of the data. That would be something like application/pdf for PDF documents, image/png for PNG image files, etc.

If you haven't store that data when you loaded the BLOB data initially, I suppose you could try writing code to inspect the first few bytes of data from the BLOB in order to try to detect what sort of file that is. That, however, would require specifying exactly what data types you want to try to inspect and then looking at the spec for each of these file types to find a reasonable signature of that file type. Obviously, that tends to be much more challenging.

Justin Cave
  • 212,688
  • 21
  • 342
  • 361
  • Can You please me just write, what You think that is better choose? Second is challenging I agree, but what is Your opinion that wold be better? Thanx one more time .. – Frink Jun 20 '14 at 06:22
  • 2
    @Frink - I thought it was clear from the answer. Storing the MIME type in a separate column is, by far, the preferable approach. – Justin Cave Jun 20 '14 at 06:37