title: correct way to make sure the uploaded file is csv file in grails?
body: <p>There is a file input that is used to upload csv files. </p>
  
  <p>Here is the documentation for multipart file class. </p>
  
  <p><a href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/multipart/commons/CommonsMultipartFile.html" rel="nofollow noreferrer">https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/multipart/commons/CommonsMultipartFile.html</a></p>
  
  <p>Now i would like to make sure the uploaded file is csv file. In other words the application only accepts csv files. There are two methods that commonsmultipartfile class offers. One is contentType. For csv file it returns application/octet-stream. Another method is originalFilename which gives the filename with extension. </p>
  
  <p><a href="https://i.stack.imgur.com/zBfAR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zBfAR.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/zagt0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zagt0.png" alt="enter image description here"></a></p>
  
  <p>So i am wondering what is the best way to make sure the uploaded file is csv file. My doubt is that checking contenttype is not enough since application/octet-stream is mime type for binary file. So do you recommend using both contenttype and originalfilename to extract the extension. I appreciate any guide. Thanks! I am using grails 2.2.</p>