-
Notifications
You must be signed in to change notification settings - Fork 235
Using S3Proxy in Java projects
Andrew Gaul edited this page Nov 17, 2016
·
18 revisions
Java projects can include the latest S3Proxy release via Maven artifacts:
<dependency>
<groupId>org.gaul</groupId>
<artifactId>s3proxy</artifactId>
<version>1.5.1</version>
</dependency>
Sonatype also provides pre-release snapshots:
<repositories>
<repository>
<id>apache-snapshots</id>
<url>https://repository.apache.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
...
<dependency>
<groupId>org.gaul</groupId>
<artifactId>s3proxy</artifactId>
<version>1.6.0-SNAPSHOT</version>
</dependency>
Instantiate S3Proxy by creating a backend BlobStore
object and a frontend S3Proxy
object. An example configuring the filesystem backend and listening on port 8080:
Properties properties = new Properties();
properties.setProperty("jclouds.filesystem.basedir", "/tmp/blobstore");
BlobStoreContext context = ContextBuilder
.newBuilder("filesystem")
.credentials("identity", "credential")
.overrides(properties)
.build(BlobStoreContext.class);
S3Proxy s3Proxy = S3Proxy.builder()
.blobStore(context.getBlobStore())
.endpoint(URI.create("http://127.0.0.1:8080"))
.build();
s3Proxy.start();
while (!s3Proxy.getState().equals(AbstractLifeCycle.STARTED)) {
Thread.sleep(1);
}
The S3Proxy Main class and unit tests demonstrate more complicated configurations: