How to identify MIME-Type from java Blob object?

HI All,

In our J2EE application, we need to upload attachments and store them as BLOB in Oracle DB.

We are storing only blob obj in table and not other info like mime-type, file name etc.

Can anyone guide me about finding meta data from BLOB/byte[]?

I have read somewhere that every file stores its meta data in byte[]..like PDF files starts with(1st 5 bytes) '%PDF-'JPEG file starts with

' FF D8 FF E0' etc.

Do java provide any API/class to find this info?

Thanks much,

shilpa.

[537 byte] By [shilpasaia] at [2007-11-26 16:34:40]
# 1

First of all this definitely is the wrong forum for this question. The problem you have is in no way JDBC-related. You would face the same problem when you load the file binary from a filesystem and throw away the file name.

Not every file stores it's 'meta data'. Assume you have a simple text file. Where should the metadata be stored ?

What you want is not possible in standard java, as java does not know all file types.

g_magossa at 2007-7-8 22:59:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
Yeah, I know this is not the right place to put file related queries. I apologize for this. As I am working with Java.sql.Blob, I thought, I would get some help on getting MIME-Type from BLOB object.Anyways, I have to find some other way of doing this.Thanks for your reply.
shilpasaia at 2007-7-8 22:59:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
> We are storing only blob obj in table and not other info like mime-type, file name etc.Then the easiest thing to do would be to stop doing that and start storing the information you need.
DrClapa at 2007-7-8 22:59:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

I think, I asked the question in wrong place as well as wrong way!!

I just wated to ask how to get meta data from byte[]? is it possible?

DB design is not in our hand and finally we are getting only byte[].

I hope, I have cleared the point this tim. Plz don't make any awful comments if this is an impossible stuff!!

shilpasaia at 2007-7-8 22:59:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...