2

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.

Leigh
  • 28,765
  • 10
  • 55
  • 103
RHPT
  • 2,560
  • 5
  • 31
  • 43

1 Answers1

4

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.

Adam Cameron
  • 29,677
  • 4
  • 37
  • 78
  • I'm working on an Ubuntu system, so if the extension is lowercase CF will return a file not found type error. – RHPT Jan 17 '14 at 14:18
  • I can run `getMimeType()` with any random file name I like. The file didn't seem to need to actually exist in the file system. – Adam Cameron Jan 17 '14 at 14:30
  • I did not know that getMimeType() only uses the extension to determine type. Seems like fileGetMimeType is a better choice, as it will look at the actual type, not just the extension. – RHPT Jan 20 '14 at 22:12
  • You do know that as of Adobe CF 10 there is the fileGetMimeType function? You can find out about it here: https://wikidocs.adobe.com/wiki/display/coldfusionen/FileGetMimeType – Larry C. Lyons Sep 25 '14 at 17:33
  • You mean as per it being mentioned in both the original question, as well as the comment you're commenting on? ;-) – Adam Cameron Sep 25 '14 at 18:44