我想在创建zip文件之后清理文件。其中一个操作是删除zip文件本身。
@RequestMapping(path = "/downloadZip", method = RequestMethod.GET)
public ResponseEntity<Resource> download(String fileName) throws IOException {
//Create a zip file and add entries
Path path = Paths.get(file.getAbsolutePath());
ByteArrayResource resource = new ByteArrayResource(Files.readAllBytes(path));
return ResponseEntity.ok()
.headers(headers)
.contentLength(file.length())
.contentType(MediaType.parseMediaType("application/octet-stream"))
.body(resource);
//Call a cleanup method
//cleanUp();
}
在JUnit测试中,我可以使用静态方法删除zip文件。
课后
.
问题
:如何定义返回后获取的方法。
谢谢!