Skip to content

Commit

Permalink
Only use S3FileSystemStore for https endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dgault committed Apr 26, 2024
1 parent 141f8be commit 44d5622
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/loci/formats/S3FileSystemStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class S3FileSystemStore implements Store {

private Path root;
AmazonS3 client;
public static final String ENDPPOINT_PROTOCOL= "https://";
protected static final Logger LOGGER =
LoggerFactory.getLogger(S3FileSystemStore.class);

Expand All @@ -97,7 +98,7 @@ public String getRoot() {

private void setupClient() {
String[] pathSplit = root.toString().split(File.separator);
String endpoint = "https://" + pathSplit[1] + File.separator;
String endpoint = "ENDPPOINT_PROTOCOL" + pathSplit[1] + File.separator;
try {
client = AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, "auto"))
Expand Down Expand Up @@ -179,7 +180,7 @@ public TreeSet<String> getGroupKeys() throws IOException {
* @throws IOException
*/
public TreeSet<String> getKeysEndingWith(String suffix) throws IOException {
return (TreeSet)Files.walk(this.root).filter((path) -> {
return (TreeSet<String>)Files.walk(this.root).filter((path) -> {
return path.toString().endsWith(suffix);
}).map((path) -> {
return this.root.relativize(path).toString();
Expand Down
12 changes: 10 additions & 2 deletions src/loci/formats/services/JZarrServiceImpl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package loci.formats.services;

import java.io.File;

/*-
* #%L
* Implementation of Bio-Formats readers for the next-generation file formats
Expand Down Expand Up @@ -79,7 +81,13 @@ public class JZarrServiceImpl extends AbstractService
public JZarrServiceImpl(String root) {
checkClassDependency(com.bc.zarr.ZarrArray.class);
if (root != null && (root.toLowerCase().contains("s3:") || root.toLowerCase().contains("s3."))) {
s3fs = new S3FileSystemStore(Paths.get(root));
String[] pathSplit = root.toString().split(File.separator);
if (!S3FileSystemStore.ENDPPOINT_PROTOCOL.contains(pathSplit[0].toLowerCase())) {
s3fs = new S3FileSystemStore(Paths.get(root));
}
else {
LOGGER.warn("Zarr Reader is not using S3FileSystemStore as this is currently for use with S3 configured with a https endpoint");
}
}
}

Expand All @@ -89,7 +97,7 @@ public void open(String file) throws IOException, FormatException {
if (s3fs == null) {
zarrArray = ZarrArray.open(file);
}
else {
else {
s3fs.updateRoot(getZarrRoot(s3fs.getRoot()) + stripZarrRoot(file));
zarrArray = ZarrArray.open(s3fs);
}
Expand Down

0 comments on commit 44d5622

Please sign in to comment.