title: Zip file getting downloaded without .zip extension in Chrome through Java
body: <ol>
  <li>I am trying to download a zip file from a fixed location present in server. </li>
  <li>In my Rest method , I am just passing the file name from client (browser) . 
  (Please see below code ).</li>
  <li><p>In my Rest method I am sending the zip file to the client.</p></li>
  <li><p>The file gets downloaded on the browser without any issue.</p></li>
  </ol>
  
  <p>My Issue is that the zip file gets downloaded on browser without .zip extension. </p>
  
  <pre><code>@RequestMapping(value = "/zip/{filePath}", method = RequestMethod.GET)
  public @ResponseBody void downloadZip(@PathVariable("filePath") String filePath, HttpServletRequest request, HttpServletResponse response) throws IOException {
  
    ServletContext context = request.getServletContext();
    File downloadFile = new File(filePath);
    FileInputStream inputStream = new FileInputStream(downloadFile);
    // get output stream of the response
    OutputStream outStream = response.getOutputStream();
  
    byte[] buffer = new byte[(int) downloadFile.length()];
    int bytesRead = -1;
  
    // write bytes read from the input stream into the output stream
    while ((bytesRead = inputStream.read(buffer)) != -1) {
      outStream.write(buffer, 0, bytesRead);
    }
    // get MIME type of the file
    String mimeType = context.getMimeType(fullPath);
    if (mimeType == null) {
      // set to binary type if MIME mapping not found
      mimeType = "application/octet-stream";
    }
    System.out.println("MIME type: " + mimeType);
  
    // set content attributes for the response
    response.setContentType(mimeType);
    response.setContentLength((int) downloadFile.length());
  
    response.setHeader("Content-Disposition",
        String.format("attachment; filename=\"%s\"", downloadFile.getName()));
    logger.error("Filename = " + downloadFile.getName());
    inputStream.close();
    outStream.close();
  }
  </code></pre>
  
  <p>PS: The file gets downloaded on some machine with ZIP and in some machine without ZIP. I have tested only on chrome (as per client requirement).
  I think, there is an issue with the Chrome settings which I need to look upon (just a guess).</p>
  
  <p>Can someone help upon this?</p>
  
  <p>Thanks in advance....</p>