小编Jav*_*rot的帖子

使用 SpringBoot 从资源中下载文件

如何从 reosurces/folderX/file.txt 获取文件

@PostMapping(value = "/uploadFile", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public ResponseEntity<Resource> uploadFile(@RequestParam("file") MultipartFile file) {
    /* 
     * FIRST I upload file
     * Next, I need to return different file in this request 
     */ 
    return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + "file.txt + "\"").body();
}
Run Code Online (Sandbox Code Playgroud)

java spring-boot

1
推荐指数
1
解决办法
2931
查看次数

标签 统计

java ×1

spring-boot ×1