问题
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:
- it's that way on purpose;
- it's outwith their control because it's Tomcat that deals with that sort of thing;
- 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