任何方式来猜测Delphi XE2上的mime类型? [英] Any way to guess the mime type on Delphi XE2?
本文介绍了任何方式来猜测Delphi XE2上的mime类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要猜测mime类型,目的是为了某些文件上传填写Content-Type标题。
I need to guess the mime type with the purpose of fill the "Content-Type" header for some file uploads.
我没有找到解决方案
我想打电话给: GetMimeType('C:File.jpg')
code> image / jpg 。
I wish to call something like: GetMimeType('C:File.jpg')
and get back image/jpg
.
最佳如果是多平台(对于win / osx),但只有适用于Windows才能使用。
Best if is multiplataform (for win/osx) but will be enough if only for windows.
推荐答案
Internet Direct(Indy)包含一个类:
Internet Direct (Indy) contains a class for this:
class TIdThreadSafeMimeTable
class TIdThreadSafeMimeTable
单位IdCustomHTTPServer
in unit IdCustomHTTPServer
HTTP服务器应用程序中的代码示例:
Code example in a HTTP server application:
Response.ContentType :=
Response.HTTPServer.MIMETable.GetFileMIMEType(FileName);
这篇关于任何方式来猜测Delphi XE2上的mime类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文