看起来您可以独立构建 SWIFT(woorea peoject 的一部分)
正如它在此处的自述文件中所述:
(com.woorea swift-client 3.0.0-SNAPSHOT)
https://github.com/woorea/openstack-java-sdk
Maven 工件 ID 应为:
openstack-java-sdk
这是一个不错的教程:
https://github.com/woorea/openstack-java-sdk/wiki/Swift-Tutorial
它有使用 SWIFT 的 java api 示例,
例如这段代码sn-p(更多详情见链接):
Properties properties = System.getProperties();
properties.put("verbose", "true");
properties.put("auth.credentials", "passwordCredentials");
properties.put("auth.username", "demo");
properties.put("auth.password", "secret0");
properties.put("auth.tenantName", "demo");
properties.put("identity.endpoint.publicURL","http://192.168.1.43:5000/v2.0");
OpenStackClient openstack = OpenStackClient.authenticate(properties);
AccountResource account = openstack.getStorageEndpoint();
account.container("hellocontainer").put();
account.container("hellocontainer").object("dir1").put();
account.container("hellocontainer").object("test1")
.put(new File("pom.xml"), new SwiftStorageObjectProperties() {{
setContentType("application/xml");
getCustomProperties().putAll(new HashMap<String, String>() {{
put("customkey.1", "customvalue.1");
}});
}});
List<SwiftStorageObject> objects = account.container("hellocontainer").get();
- 请记住,在使用 openstack 的 API 时,您很可能需要进行身份验证(获取令牌等),因此您也需要 Keystone 库
www.programcreek.com/java-api-examples/index.php?api=com.woorea.openstack.keystone.Keystone
希望这会有所帮助。