0

在Java中使用云文件api时是否可以使用servicenet?目前我使用它如下:

ContextBuilder cb = ContextBuilder.newBuilder(config.getProvider())
    .credentials(config.getUserName(), config.getApiKey()).modules(modules);
CloudFilesApi cfa = cb.buildApi(CloudFilesApi.class);

我问这个是因为我曾经使用具有布尔参数的python客户端来选择是使用公共网络还是服务网络:

cf = pyrax.connect_to_cloudfiles(region=CDN_REGION, public=CDN_USEPUBLIC)
4

1 回答 1

0
Iterable<Module> modules = ImmutableSet.<Module> of(new SLF4JLoggingModule(),
        new InternalUrlModule());

ContextBuilder builder = ContextBuilder.newBuilder(PROVIDER)
        .modules(modules)
        .credentials(username, apiKey);
  blobStore = builder.buildView(RegionScopedBlobStoreContext.class).getBlobStore(REGION);
  cloudFiles = blobStore.getContext().unwrapApi(CloudFilesApi.class);

您需要确保将 InternalUrlModule 添加到模块列表中。这反过来将使 jclouds 在连接到服务时使用适用的 ServiceNet 端点。

于 2015-10-08T16:26:17.323 回答