title: Grails force controller download file
body: <p>I have following code :</p>
  
  <pre><code>def getMyFile(){
  
  
      File myFile = new File("/path/to/file.xsl")
  
      try{
  
          response.setHeader "Content-disposition", "attachment; filename=${myFile.name}"
          response.contentType = new MimetypesFileTypeMap().getContentType(myFile )
          response.outputStream &lt;&lt; myFile .bytes
          response.outputStream.flush()
      }
  
      catch (e){
          println(e.message)
      }
  
  }
  </code></pre>
  
  <p>When accessing this controller action, I want the browser to download the excel file.</p>
  
  <p>The code does not create any errors in the console, but the file is not downloaded correctly.</p>