Composite
Posted on June 30, 2021
** Aug 18, 2021 DO NOT USE THIS METHOD **
jclouds will make signature with your custom domain and DEFAULT region(us-east-1), and you'll see 403 Forbidden. You can use hack method(patched jcloud, override jcloud's class in your app, java-agent, etc) but it's not recommended if you have no time. so,
DO NOT USE THIS METHOD. CONTACT YOUR NETWORK MANAGER TO GRANT ACCESS TO AWS WITH FIREWALL OR PROXY FOR FIGURE IT OUT THIS ISSUE!
When you get BlobStoreContext
from ContextBuilder
, it provides endpoint
method for initiize endpoint.
BlobStoreContext context = ContextBuilder.newBuilder("aws-s3")
.credentials(identity, credentials)
.endpoint(endpoint)
.buildView(AWSS3BlobStoreContext.class);
But it does not work, it will throws NullpointerException
when putting blob, weird.
So, if you want set custom endpoint, you must set endpoint in override property. (fixed region due to your firewall rules, custom domain with proxy, etc.)
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
Property override = new Property();
override.setProperty(PROPERTY_ENDPOINT, endpoint);
BlobStoreContext context = ContextBuilder.newBuilder("aws-s3")
.credentials(identity, credentials)
.overrides(override)
.buildView(AWSS3BlobStoreContext.class);
Plus, if you want enable logging for monitoring how to works on jCloud, set a module with SLF4JLoggingModule
. it will requires additional dependency: org.apache.jclouds.driver:jclouds-slf4j:${sameVersionWithYourjCloud}
Iterable<Module> modules = ImmutableSet.<Module>of(new SLF4JLoggingModule());
BlobStoreContext context = ContextBuilder.newBuilder("aws-s3")
.credentials(identity, credentials)
.modules(modules)
.buildView(AWSS3BlobStoreContext.class);
That's all. Happy coding!
Posted on June 30, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.