diff --git a/src/loci/formats/S3FileSystemStore.java b/src/loci/formats/S3FileSystemStore.java index dde2339..5d908e7 100644 --- a/src/loci/formats/S3FileSystemStore.java +++ b/src/loci/formats/S3FileSystemStore.java @@ -123,8 +123,11 @@ public S3FileSystemStore(Path rootPath) { @Override public InputStream getInputStream(String key) throws IOException { + // Get the base bucket name from splitting the root path and removing the prefixed protocol and end-point String[] pathSplit = root.toString().split(File.separator); String bucketName = pathSplit[2]; + + // Append the desired key onto the remaining prefix String key2 = root.toString().substring(root.toString().indexOf(pathSplit[3]), root.toString().length()) + File.separator + key; try { @@ -205,10 +208,12 @@ public Stream getRelativeLeafKeys(String key) throws IOException { private TreeSet getKeysFor(String suffix) throws IOException { TreeSet keys = new TreeSet(); - + + // Get the base bucket name from splitting the root path and removing the prefixed protocol and end-point String[] pathSplit = root.toString().split(File.separator); - String bucketName = pathSplit[2]; + + // Append the desired key onto the remaining prefix String key2 = root.toString().substring(root.toString().indexOf(pathSplit[3]), root.toString().length()); ListObjectsRequest listObjectsRequest = new ListObjectsRequest() @@ -249,11 +254,13 @@ private TreeSet getKeysFor(String suffix) throws IOException { public ArrayList getFiles() throws IOException { ArrayList keys = new ArrayList(); - + + // Get the base bucket name from splitting the root path and removing the prefixed protocol and end-point String[] pathSplit = root.toString().split(File.separator); String bucketName = pathSplit[2]; + + // Append the desired key onto the remaining prefix String key2 = root.toString().substring(root.toString().indexOf(pathSplit[3]), root.toString().length()); - ListObjectsRequest listObjectsRequest = new ListObjectsRequest() .withBucketName(bucketName) .withPrefix(key2)