|
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSON;
|
6
|
6
|
import lombok.Data;
|
7
|
7
|
import net.lingala.zip4j.ZipFile;
|
8
|
8
|
import net.lingala.zip4j.exception.ZipException;
|
|
9
|
+import net.lingala.zip4j.io.outputstream.ZipOutputStream;
|
9
|
10
|
import net.lingala.zip4j.model.ZipParameters;
|
10
|
11
|
import org.springframework.beans.factory.annotation.Autowired;
|
11
|
12
|
import org.springframework.stereotype.Component;
|
|
@@ -40,14 +41,16 @@ public class ZipUtil {
|
40
|
41
|
return zipFile;
|
41
|
42
|
}
|
42
|
43
|
|
|
44
|
+ FileOutputStream fos = new FileOutputStream(zipFile.getFile());
|
|
45
|
+ ZipOutputStream zos = new ZipOutputStream(fos);
|
43
|
46
|
ZipParameters zipParameters = new ZipParameters();
|
44
|
47
|
|
45
|
48
|
for (RFile f : files) {
|
46
|
49
|
zipParameters.setFileNameInZip(f.getName());
|
|
50
|
+ zos.putNextEntry(zipParameters);
|
47
|
51
|
byte[] data = httpUtils.download(f.getUrl());
|
48
|
|
- InputStream inputStream = new ByteArrayInputStream(data);
|
49
|
|
- zipFile.addStream(inputStream, zipParameters);
|
50
|
|
- inputStream.close();
|
|
52
|
+ zos.write(data);
|
|
53
|
+ zos.closeEntry();
|
51
|
54
|
}
|
52
|
55
|
|
53
|
56
|
return zipFile;
|