Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Add aws s3:// uri support #565

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add aws s3:// uri support
Fixes gh-361
  • Loading branch information
tmnuwan12 committed Jun 6, 2020
commit c1027bfb7940deb898618415d61f23408a17e529
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
Expand Down Expand Up @@ -143,6 +145,10 @@ public URL getURL() throws IOException {
"/" + this.bucketName + "/" + this.objectName);
}

public URI getS3URI() throws URISyntaxException {
tmnuwan12 marked this conversation as resolved.
Show resolved Hide resolved
return new URI("S3", "//" + this.bucketName + "/" + this.objectName, null);
tmnuwan12 marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
public File getFile() throws IOException {
throw new UnsupportedOperationException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URL;
import java.util.Date;

Expand Down Expand Up @@ -219,8 +220,6 @@ public void getUrl_existingObject_returnsUrlWithS3Prefix() throws Exception {

AmazonS3Client amazonS3 = mock(AmazonS3Client.class);

when(amazonS3.getRegion()).thenReturn(Region.EU_Ireland);

// Act
SimpleStorageResource simpleStorageResource = new SimpleStorageResource(amazonS3,
"bucket", "object", new SyncTaskExecutor());
Expand All @@ -231,6 +230,23 @@ public void getUrl_existingObject_returnsUrlWithS3Prefix() throws Exception {

}

@Test
public void getUrl_existingObject_returnsUrlWithS3Scheme() throws Exception {

AmazonS3Client amazonS3 = mock(AmazonS3Client.class);

when(amazonS3.getRegion()).thenReturn(Region.EU_Ireland);

// Act
SimpleStorageResource simpleStorageResource = new SimpleStorageResource(amazonS3,
"bucket", "object", new SyncTaskExecutor());

// Assert
assertThat(simpleStorageResource.getS3URI())
.isEqualTo(new URI("S3://bucket/object"));

}

@Test
public void getFile_existingObject_throwsMeaningFullException() throws Exception {

Expand Down