Search code examples
grailsmime-typesgrails-2.0

How to get the Mime Type of a request in Grails?


How to get the Mime Type of a request in Grails?

I used:

def f = request.getFile('image')
def mimeType = f.getContentType()

but this does not always returns the correct mime file type. How can I get File of file user selected for update?


Solution

  • That will return whatever content type the browser sent for that particular part of the posted multipart/form-data. Whether or not this is the "correct" type is a different question...