From 5b708a4583b7ce1287e88d12958a4e0759e4fa8d Mon Sep 17 00:00:00 2001 From: Stephan Preibisch Date: Sat, 14 Sep 2024 11:22:53 -0400 Subject: [PATCH] change order of trying for s3 writing (first with credentials, if that doesn't work anonymous) --- src/main/java/util/URITools.java | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/java/util/URITools.java b/src/main/java/util/URITools.java index 7234edff..2816cae9 100644 --- a/src/main/java/util/URITools.java +++ b/src/main/java/util/URITools.java @@ -170,16 +170,16 @@ else if ( format.equals( StorageFormat.HDF5 )) try { - System.out.println( "Trying anonymous writing ..." ); - n5w = new N5Factory().openWriter( format, uri ); + System.out.println( "Trying writing with credentials ..." ); + N5Factory factory = new N5Factory(); + factory.s3UseCredentials(); + n5w = factory.openWriter( format, uri ); } catch ( Exception e ) { System.out.println( "Anonymous failed; trying writing with credentials ..." ); - N5Factory factory = new N5Factory(); - factory.s3UseCredentials(); - n5w = factory.openWriter( format, uri ); + n5w = new N5Factory().openWriter( format, uri ); } return n5w; @@ -270,17 +270,16 @@ else if ( uri.toString().toLowerCase().endsWith( ".n5" ) ) try { - System.out.println( "Trying anonymous writing ..." ); - n5w = new N5Factory().openWriter( uri.toString() ); - } - catch ( Exception e ) - { - System.out.println( "Anonymous failed; trying writing with credentials ..." ); - + System.out.println( "Trying writing with credentials ..." ); N5Factory factory = new N5Factory(); factory.s3UseCredentials(); n5w = factory.openWriter( uri.toString() ); } + catch ( Exception e ) + { + System.out.println( "Writing with credentials failed; trying anonymous writing ..." ); + n5w = new N5Factory().openWriter( uri.toString() ); + } return n5w;