Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/main/java/com/aliyuncs/fc/utils/ZipUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ public static void zipDir(File dir, String zipName) throws IOException {
ZipOutputStream zos = new ZipOutputStream(fos);
for (String filePath : fileNames) {
// for ZipEntry we need to keep only relative file path, so we used substring on absolute path
ZipEntry ze = new ZipEntry(
filePath.substring(dir.getAbsolutePath().length() + 1, filePath.length()));
String zipFilePath = filePath.substring(dir.getAbsolutePath().length() + 1, filePath.length());
if (File.separatorChar != '/') {
zipFilePath = zipFilePath.replace("\\", "/");
}
ZipEntry ze = new ZipEntry(zipFilePath);
zos.putNextEntry(ze);
// read the file and write to ZipOutputStream
FileInputStream fis = new FileInputStream(filePath);
Expand Down