diff --git a/src/main/java/com/bc/zarr/storage/ZipStore.java b/src/main/java/com/bc/zarr/storage/ZipStore.java index 65953d8..9585bfd 100644 --- a/src/main/java/com/bc/zarr/storage/ZipStore.java +++ b/src/main/java/com/bc/zarr/storage/ZipStore.java @@ -35,6 +35,8 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.URI; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.nio.file.FileSystem; import java.nio.file.FileSystemAlreadyExistsException; import java.nio.file.FileSystems; @@ -54,7 +56,7 @@ public ZipStore(Path zipFilePath) throws IOException { if (!Files.exists(zipFilePath)) { zipParams.put("create", "true"); } - final URI uri = URI.create("jar:file:" + zipFilePath.toUri().getPath()); + final URI uri = URI.create("jar:" + zipFilePath.toUri()); zfs = getFileSystem(zipParams, uri); internalRoot = zfs.getRootDirectories().iterator().next(); } diff --git a/src/test/java/com/bc/zarr/storage/ZipStoreTest.java b/src/test/java/com/bc/zarr/storage/ZipStoreTest.java index 8f67266..53b9cc1 100644 --- a/src/test/java/com/bc/zarr/storage/ZipStoreTest.java +++ b/src/test/java/com/bc/zarr/storage/ZipStoreTest.java @@ -73,6 +73,16 @@ public void tearDown() throws Exception { } } + + @Test + public void createZipStoreWithSpaceInPath() throws IOException { + Path spaceDir = testDataPath.resolve("folder name"); + Files.createDirectories(spaceDir); + Path resolve = spaceDir.resolve("zipped.znap.zip"); + store = new ZipStore(resolve); + assertThat(store).isNotNull(); + } + @Test public void createFileSystemStore_withPathString_withoutFS() throws NoSuchFieldException, IllegalAccessException { //execution