List of usage examples for org.springframework.http HttpHeaders CONTENT_DISPOSITION
String CONTENT_DISPOSITION
To view the source code for org.springframework.http HttpHeaders CONTENT_DISPOSITION.
Click Source Link
From source file:org.apache.servicecomb.demo.edge.business.Impl.java
@GetMapping(path = "/download") @ApiResponses({ @ApiResponse(code = 200, response = File.class, message = ""), }) public ResponseEntity<InputStream> download() throws IOException { return ResponseEntity.ok().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE) .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=download.txt") .body(new ByteArrayInputStream("download".getBytes(StandardCharsets.UTF_8))); }
From source file:org.apache.servicecomb.demo.springmvc.server.DownloadSchema.java
@GetMapping(path = "/tempFileEntity") public ResponseEntity<Part> tempFileEntity(String content) throws IOException { File file = createTempFile(content); return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=tempFileEntity.txt") .body(new FilePart(null, file).setDeleteAfterFinished(true)); }
From source file:org.apache.servicecomb.demo.springmvc.server.DownloadSchema.java
@GetMapping(path = "/entityResource") @ApiResponses({ @ApiResponse(code = 200, response = File.class, message = ""), }) public ResponseEntity<Resource> entityResource(String content) throws IOException { return ResponseEntity.ok().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE) .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=entityResource.txt") .body(new ByteArrayResource(content.getBytes(StandardCharsets.UTF_8))); }
From source file:org.apache.servicecomb.demo.springmvc.server.DownloadSchema.java
@GetMapping(path = "/entityInputStream") @ApiResponses({ @ApiResponse(code = 200, response = File.class, message = ""), }) public ResponseEntity<InputStream> entityInputStream(String content) throws IOException { return ResponseEntity.ok().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE) .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=entityInputStream.txt") .body(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))); }
From source file:org.apache.servicecomb.demo.springmvc.server.DownloadSchema.java
@GetMapping(path = "/bytes") @ApiResponses({ @ApiResponse(code = 200, response = File.class, message = ""), }) public ResponseEntity<byte[]> bytes(String content) throws IOException { return ResponseEntity.ok().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE) .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=bytes.txt") .body(content.getBytes(StandardCharsets.UTF_8)); }
From source file:org.apache.servicecomb.demo.springmvc.server.DownloadSchema.java
@GetMapping(path = "/netInputStream") @ApiResponses({ @ApiResponse(code = 200, response = File.class, message = ""), }) public ResponseEntity<InputStream> netInputStream(String content) throws IOException { URL url = new URL("http://localhost:9000/download/netInputStream?content=" + URLEncoder.encode(content, StandardCharsets.UTF_8.name())); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); return ResponseEntity.ok().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE) .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=netInputStream.txt") .body(conn.getInputStream()); }
From source file:org.apache.servicecomb.it.schema.DownloadSchema.java
@GetMapping(path = "/entityResource") @ApiResponses({ @ApiResponse(code = 200, response = File.class, message = ""), }) public ResponseEntity<Resource> entityResource(String content) { return ResponseEntity.ok().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE) .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=entityResource.txt") .body(new ByteArrayResource(content.getBytes(StandardCharsets.UTF_8))); }
From source file:org.apache.servicecomb.it.schema.DownloadSchema.java
@GetMapping(path = "/entityInputStream") @ApiResponses({ @ApiResponse(code = 200, response = File.class, message = ""), }) public ResponseEntity<InputStream> entityInputStream(String content) { return ResponseEntity.ok().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE) .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=entityInputStream.txt") .body(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))); }
From source file:org.apache.servicecomb.it.schema.DownloadSchema.java
@GetMapping(path = "/bytes") @ApiResponses({ @ApiResponse(code = 200, response = File.class, message = ""), }) public ResponseEntity<byte[]> bytes(String content) { return ResponseEntity.ok().header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE) .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=bytes.txt") .body(content.getBytes(StandardCharsets.UTF_8)); }
From source file:org.apache.servicecomb.it.schema.DownloadSchema.java
@GetMapping(path = "/netInputStream") @ApiResponses({ @ApiResponse(code = 200, response = File.class, message = ""), }) public ResponseEntity<InputStream> netInputStream(String content) throws IOException { URL url = new URL("http://localhost:" + server.getLocalPort() + "/download/netInputStream?content=" + URLEncoder.encode(content, StandardCharsets.UTF_8.name())); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); ResponseEntity<InputStream> responseEntity = ResponseEntity.ok() .header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE) .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=netInputStream.txt") .body(conn.getInputStream()); conn.disconnect();//from www. ja v a2 s. c o m return responseEntity; }