我正在尝试使用Spring Boot上传zip文件。Zip文件包含多个不同类型的文件,例如.txt,.pdf,.docx
在将每个文件上传到Cloud Storage时遇到问题,因为我无法将每个zip条目转换为InputStream。我想从压缩文件中上传每个文件
下面是我的代码
@PostMapping("/testZipUpload")
public ResponseEntity testZipUpload(@RequestParam(value = "uploadFile") MultipartFile multipartFile) throws IOException {
byte[] bytes = multipartFile.getBytes();
ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(bytes));
ZipEntry entry = null;
while ((entry = zis.getNextEntry()) != null) {
//Logic to Convert each ZipEntry to Input Stream
}
zis.closeEntry();
zis.close();
return ResponseEntity.ok().build();
}