** 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!
Top comments (1)
Hi, Ukjin. I have trouble to figure out the endpoint of s3 bucket for Jcloud. For example,
have a bucket, s3://abc-edf. Like to create a folder, myFoldert, under s3://abc-edf/myFolder. Then store data under myFolder. When I create blobStoreContext, I set endpoint to abc-edf.s3.us-east-2.amazonaws.com. It doesn't work. Actually, it created a bucket called myFolder, not folder under s3://abc-edf.
Appreciate your help,
Tony