Problems determining a file's mime type in ColdFusion

别来无恙 提交于 2020-01-04 13:46:06

问题


When I try to determine a file's mime type with getPageContext().getServletContext().getMimeType(), it returns undefined if the extension is in uppercase (e.g., image.JPG). Has anyone run into this before? I know there is FileGetMimeType, but that gives me another set of issues within the codebase in which I'm working. I am running ColdFusion 10.


回答1:


This appears to be a regression in ColdFusion 10 (it works fine on CF9). I'd go through the motions of raising a bug, but Adobe will more than likely say one or more of:

  1. it's that way on purpose;
  2. it's outwith their control because it's Tomcat that deals with that sort of thing;
  3. those methods are undocumented in CFML therefore unsupported (although they are documented in the ServletContext spec)

None are particularly satisfactory, but it's an easy out for Adobe.

TBH, I'd just lowercase the filename before passing it to the function. It's not like it needs to be the actual name of a real file.



来源:https://stackoverflow.com/questions/21177749/problems-determining-a-files-mime-type-in-coldfusion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!