Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename error #100

Open
jackchs opened this issue Feb 28, 2018 · 0 comments
Open

rename error #100

jackchs opened this issue Feb 28, 2018 · 0 comments

Comments

@jackchs
Copy link

jackchs commented Feb 28, 2018

    File baseDir = new File("/home/test");
    File zipFile = new File("/home/test.zip");
    try (FileOutputStream fos = new FileOutputStream(zipFile)) {
      ZipUtil.pack(baseDir, fos, new NameMapper() {
        @Override
        public String map(String name) {
          Map<String, String> map = new HashMap<>();
          map.put("folder/file", "证明及协议/file.jpg");
          map.put("folder/", "证明及协议/");
          return map.get(name);
        }
      });
    } catch (IOException e) {
    }

Rename the folder to "证明及协议/" or some specific string, and the zipFile will contain the file with the same name as the folder, causing the decompression file to fail.
test.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant