To download a file from a Spring controller, you can use the ResponseEntity class along with the InputStreamResource class.