Skip to content

Commit

Permalink
OAP-000 FileSystem: rm getPublicURI
Browse files Browse the repository at this point in the history
  • Loading branch information
galaxina committed Dec 5, 2024
1 parent 328692f commit 862843d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.ByteBuffer;
import java.nio.file.Path;
import java.time.Instant;
Expand Down Expand Up @@ -275,7 +276,11 @@ public String getName() {

@Override
public URI getUri() {
return s3Client.utilities().parseUri( URI.create( path.toString() ) ).uri();
try {
return s3Client.utilities().getUrl( builder -> builder.bucket( path.container ).key( path.path ).build() ).toURI();
} catch( URISyntaxException e ) {
throw new CloudException( e );
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.util.Map;

Expand Down Expand Up @@ -93,7 +95,7 @@ public void testGetOutputStream() throws IOException {
}

@Test
public void testGetMetadata() {
public void testGetMetadata() throws URISyntaxException {
Path path = testDirectoryFixture.testPath( "my-file.txt" );
Files.write( path, "test string", ContentWriter.ofString() );

Expand All @@ -103,6 +105,7 @@ public void testGetMetadata() {
FileSystem.StorageItem item = fileSystem.getMetadata( new CloudURI( "s3", TEST_BUCKET, "/logs/file.txt" ) );
assertThat( item.getLastModified() ).isLessThanOrEqualTo( new DateTime( DateTimeZone.UTC ) );
assertThat( item.getSize() ).isEqualTo( 11L );
assertThat( item.getUri() ).isEqualTo( new URI( "http://localhost:" + s3mockFixture.getHttpPort() + "/test-bucket/logs/file.txt" ) );

assertThat( fileSystem.getMetadata( new CloudURI( "s3", TEST_BUCKET, "/unknown.txt" ) ) ).isNull();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -117,13 +116,6 @@ public void copy( CloudURI source, CloudURI destination, Map<String, String> tag
}
}

private DateTime toDateTime( Date date ) {
if( date == null ) {
return null;
}
return new DateTime( date );
}

public PageSet<? extends StorageItem> list( CloudURI path, ListOptions listOptions ) throws CloudException {
return getCloudApi( path ).list( path, listOptions );
}
Expand Down

0 comments on commit 862843d

Please sign in to comment.