Skip to content

Commit

Permalink
S3FileSystemStore: Add comments for path splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
dgault committed May 14, 2024
1 parent 2bfe3db commit a54a40e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/loci/formats/S3FileSystemStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -205,10 +208,12 @@ public Stream<String> getRelativeLeafKeys(String key) throws IOException {

private TreeSet<String> getKeysFor(String suffix) throws IOException {
TreeSet<String> keys = new TreeSet<String>();


// 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()
Expand Down Expand Up @@ -249,11 +254,13 @@ private TreeSet<String> getKeysFor(String suffix) throws IOException {

public ArrayList<String> getFiles() throws IOException {
ArrayList<String> keys = new ArrayList<String>();


// 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)
Expand Down

0 comments on commit a54a40e

Please sign in to comment.