title: download file java spring rest api
body: <p>i want to make a rest api controller (spring boot) that when petitioned with a get will allow me to download an excel file. currently i have this endpoint:</p>
  
  <pre><code>@RequestMapping(value = "/download.xls", method = RequestMethod.GET)
  public ResponseEntity Survey_Reports(@RequestParam(value = "evaluated") String evaluated){
  
      return surveyService.getSurveysFile(evaluated);
  
  }
  </code></pre>
  
  <p>wich ultimately calls to this method:</p>
  
  <pre><code>public static ResponseEntity getDownloadResponse() {
  
      File file2Upload = new File("Survey_Reports.xls");
  
      Path path = Paths.get(file2Upload.getAbsolutePath());
      ByteArrayResource resource = null;
      try {
          resource = new ByteArrayResource(Files.readAllBytes(path));
      } catch (IOException e) {
          logger.error("there was an error getting the file bytes ", e);
      }
  
      return ResponseEntity.ok()
              .contentLength(file2Upload.length())
  
  //this line doesnt seem to work as i set the file format in the controller request mapping
              .contentType(MediaType.parseMediaType("application/vnd.ms-excel"))
              .body(resource);
  }
  </code></pre>
  
  <p>everything seems to work semi-fine as i get the download.xls(as the mapping) file correclty, but now i want to make the downloaded file have some specific name like: evaluatedName.xls or userDateEndDate.xls or some other stuff, is there a way to edit the response entity to do so? so that i dont have to name the mapping "download.xls"</p>