I have a table in which the documents were saved in PDF, some of them I want to create a web app, pictures To show (which can be either PDF, either JPG), in the same control.
If I set the response then I can see the PDF. Content Type = "Application / PDF" or Image If I set "App / JPG" but the problem is how can I get the file type, which can only be a saved stream in the database? Does the file type information in the stream contain?
Thank you. No, there is a content type associated with it in a stream if you had the original file name,
You can try to get that content type, but it will not be useless.
Many file formats have a series of "magic bytes", which allows you to locate (maybe) be in the file. PDF, for example, byte starts with "% PDF" (Note: I am not an expert on PDF, and there may be a situation where this is not true).
If you do not have any other option, you can use different libraries to parse the file until you have done the job (system drawings .image.phonstream (), iTextSharp , e.t.c).
Comments
Post a Comment