How can I get MIME type of an InputStream of a file that is being uploaded?

前端 未结 8 1409
离开以前
离开以前 2020-12-30 21:51

Simple question: how can I get MIME type (or content type) of an InputStream, without saving file, for a file that a user is uploading to my servlet?

8条回答
  •  不知归路
    2020-12-30 22:18

    You can check the Content-Type header field and have a look at the extension of the filename used. For everything else, you have to run more complex routines, like checking by Tikaetc.

提交回复
热议问题