Skip to content

Commit

Permalink
fix reading/writing of arbitrary files to cloud storage
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanPreibisch committed Sep 25, 2024
1 parent 484b78d commit 7614704
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/main/java/util/URITools.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ else if ( URITools.isS3( xmlURI ) || URITools.isGC( xmlURI ) )
try
{
pb = URITools.parseCloudLink( xmlURI.toString() );
kva = URITools.getKeyValueAccessForBucket( pb );
kva = URITools.getWriteKeyValueAccessForBucket( pb );
}
catch ( Exception e )
{
Expand Down Expand Up @@ -298,7 +298,7 @@ else if ( URITools.isS3( xmlURI ) || URITools.isGC( xmlURI ) )
//super.load(null, xmlURI); // how do I use this?

final ParsedBucket pb = URITools.parseCloudLink( xmlURI.toString() );
final KeyValueAccess kva = URITools.getKeyValueAccessForBucket( pb );
final KeyValueAccess kva = URITools.getReadKeyValueAccessForBucket( pb );

final SAXBuilder sax = new SAXBuilder();
Document doc;
Expand Down Expand Up @@ -330,22 +330,32 @@ else if ( URITools.isS3( xmlURI ) || URITools.isGC( xmlURI ) )
}
}

/*
public static KeyValueAccess getKeyValueAccessForBucket( String bucketUri )
{
final N5Reader n5r = new N5Factory().openReader( StorageFormat.N5, bucketUri );
final KeyValueAccess kva = ((GsonKeyValueN5Reader)n5r).getKeyValueAccess();
return kva;
}
*/

public static KeyValueAccess getKeyValueAccessForBucket( ParsedBucket pb )
public static KeyValueAccess getReadKeyValueAccessForBucket( final ParsedBucket pb )
{
final N5Reader n5r = new N5Factory().openReader( StorageFormat.N5, pb.protocol + pb.bucket );
final N5Reader n5r = instantiateN5Reader(StorageFormat.N5, URI.create( pb.protocol + pb.bucket ) );//new N5Factory().openReader( StorageFormat.N5, pb.protocol + pb.bucket );
final KeyValueAccess kva = ((GsonKeyValueN5Reader)n5r).getKeyValueAccess();

return kva;
}

public static KeyValueAccess getWriteKeyValueAccessForBucket( final ParsedBucket pb )
{
final N5Writer n5w = instantiateN5Writer(StorageFormat.N5, URI.create( pb.protocol + pb.bucket ) );//new N5Factory().openReader( StorageFormat.N5, pb.protocol + pb.bucket );
final KeyValueAccess kva = ((GsonKeyValueN5Reader)n5w).getKeyValueAccess();

return kva;
}

public static ParsedBucket parseCloudLink( final String uri )
{
System.out.println( "Parsing link path for '" + uri + "':" );
Expand Down

0 comments on commit 7614704

Please sign in to comment.