spring-guides / gs-uploading-files

Uploading Files :: Learn how to build a Spring application that accepts multi-part file uploads.
http://spring.io/guides/gs/uploading-files/
Apache License 2.0
469 stars 503 forks source link

download as files (or problem with binaries) #28

Closed xenoterracide closed 8 years ago

xenoterracide commented 8 years ago

Ran into a problem uploading a tar.gz, in that it downloads as f.txt this will fix that, but creates the problem that everything is then downloaded instead. Not sure if there's a better way to do it.

 Resource resource = resourceLoader.getResource( root.resolve( filename ).toUri().toString() );
            return ResponseEntity.ok()
                    .header( HttpHeaders.CONTENT_DISPOSITION, root.resolve( filename ).toFile().getName() )
                    .body( resource );
bclozel commented 8 years ago

Fixed with #30