RHPT
RHPT

Reputation: 2650

Problems determining a file's mime type in ColdFusion

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.

Upvotes: 2

Views: 1424

Answers (1)

Adam Cameron
Adam Cameron

Reputation: 29870

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.

Upvotes: 4

Related Questions