Skip to content

Commit

Permalink
Merge pull request #3 from StephanPreibisch/main
Browse files Browse the repository at this point in the history
fix issues with loading with or without AWS credentials
  • Loading branch information
tpietzsch authored Sep 26, 2024
2 parents 4568752 + 7c0f0e6 commit 0b800b9
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main/java/org/bigdataviewer/n5/XmlIoN5CloudImageLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import org.janelia.saalfeldlab.n5.N5Reader;
import org.janelia.saalfeldlab.n5.universe.N5Factory;
import org.janelia.saalfeldlab.n5.universe.N5Factory.StorageFormat;
import org.jdom2.Element;

import mpicbg.spim.data.XmlHelpers;
Expand Down Expand Up @@ -72,7 +73,23 @@ public N5CloudImageLoader fromXml( final Element elem, final URI basePathURI, fi
{
// final String version = elem.getAttributeValue( "version" );
final URI uri = XmlHelpers.loadPathURI( elem, "n5", basePathURI );
final N5Reader n5Reader = N5Factory.createReader( uri.toString() );
//final N5Reader n5Reader = N5Factory.createReader( uri.toString() );

N5Reader n5Reader;

try
{
//System.out.println( "Trying reading with credentials ..." );
N5Factory factory = new N5Factory();
factory.s3UseCredentials();
n5Reader = factory.openReader( StorageFormat.N5, uri );
}
catch ( Exception e )
{
//System.out.println( "With credentials failed; trying anonymous ..." );
n5Reader = new N5Factory().openReader( StorageFormat.N5, uri );
}

return new N5CloudImageLoader( n5Reader, uri, sequenceDescription );
}
}

0 comments on commit 0b800b9

Please sign in to comment.