ZipEntry转换成MultipartFile代码
时间: 2023-03-16 16:43:48 浏览: 602
Java利用MultipartFile实现上传多份文件的代码
可以使用以下代码将ZipEntry转换成MultipartFile:FileInputStream fis = new FileInputStream(zipEntry);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int nRead;
byte[] data = new byte[16384];
while ((nRead = fis.read(data, 0, data.length)) != -1) {
baos.write(data, 0, nRead);
}
baos.flush();
byte[] bytes = baos.toByteArray();MultipartFile result = new MockMultipartFile(zipEntry.getName(), bytes);
阅读全文