本文整理汇总了Java中org.jclouds.openstack.swift.v1.features.ObjectApi类的典型用法代码示例。如果您正苦于以下问题:Java ObjectApi类的具体用法?Java ObjectApi怎么用?Java ObjectApi使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObjectApi类属于org.jclouds.openstack.swift.v1.features包,在下文中一共展示了ObjectApi类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteObjectsAndContainer
import org.jclouds.openstack.swift.v1.features.ObjectApi; //导入依赖的package包/类
/**
* This will delete all containers that start with {@link Constants#CONTAINER} and the objects within those containers.
*/
private void deleteObjectsAndContainer() {
System.out.format("Delete Container%n");
List<Container> containers = cloudFiles.getContainerApi(REGION)
.list(ListContainerOptions.Builder.prefix(CONTAINER)).toList();
for (Container container: containers) {
System.out.format(" %s%n", container.getName());
ObjectApi objectApi = cloudFiles.getObjectApi(REGION, container.getName());
ObjectList objects = objectApi.list();
for (SwiftObject object: objects) {
System.out.format(" %s%n", object.getName());
objectApi.delete(object.getName());
}
cloudFiles.getContainerApi(REGION).deleteIfEmpty(container.getName());
}
}
示例2: createObjectFromFile
import org.jclouds.openstack.swift.v1.features.ObjectApi; //导入依赖的package包/类
/**
* This method will put a plain text object into the container.
*/
private void createObjectFromFile() throws IOException {
System.out.format("Create Object From File%n");
File tempFile = File.createTempFile(FILENAME, SUFFIX);
try {
Files.write("Hello Cloud Files", tempFile, Charsets.UTF_8);
ObjectApi objectApi = cloudFiles.getObjectApi(REGION, CONTAINER_PUBLISH);
ByteSource byteSource = Files.asByteSource(tempFile);
Payload payload = Payloads.newByteSourcePayload(byteSource);
objectApi.put(FILENAME + SUFFIX, payload);
} finally {
tempFile.delete();
}
}
示例3: getAssetDirectLink
import org.jclouds.openstack.swift.v1.features.ObjectApi; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public URI getAssetDirectLink(String id, String root, String filePath) throws IOException {
ContainerAndName can = getContainerAndName(id, root, filePath);
ObjectApi objectApi = swiftApi.getObjectApi(region, can.container);
SwiftObject so = objectApi.get(can.name, GetOptions.NONE);
if(so == null){
throw new IOException("No object found for " + id);
}
return so.getUri();
}
示例4: getInputStream
import org.jclouds.openstack.swift.v1.features.ObjectApi; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public InputStream getInputStream(String id, String root, String filePath) throws IOException {
ContainerAndName can = getContainerAndName(id, root, filePath);
ObjectApi objectApi = swiftApi.getObjectApi(region, can.container);
SwiftObject so = objectApi.get(can.name, GetOptions.NONE);
if(so == null){
throw new IOException("No object found for " + id);
}
//we copy this to a byte array first since Sakai does some funny stuff
//and with the stream and then swift and sakai don't play nice.
return new ByteArrayInputStream(FileCopyUtils.copyToByteArray(so.getPayload().openStream()));
}
示例5: delete
import org.jclouds.openstack.swift.v1.features.ObjectApi; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean delete(String id, String root, String filePath) {
ContainerAndName can = getContainerAndName(id, root, filePath);
ObjectApi objectApi = swiftApi.getObjectApi(region, can.container);
if(objectApi.getWithoutBody(can.name) == null){
return false;
}else{
objectApi.delete(can.name);
deleteContainerIfEmpty(can.container);
return true;
}
}
示例6: deleteCloudFiles
import org.jclouds.openstack.swift.v1.features.ObjectApi; //导入依赖的package包/类
private void deleteCloudFiles() throws IOException {
CloudFilesApi cloudFilesApi = ContextBuilder.newBuilder(System.getProperty("provider.cf", "rackspace-cloudfiles-us"))
.credentials(username, apiKey)
.buildApi(CloudFilesApi.class);
for (String region : cloudFilesApi.getConfiguredRegions()) {
try {
System.out.format("Delete Containers of Objects in %s%n", region);
ContainerApi containerApi = cloudFilesApi.getContainerApi(region);
for (Container container : containerApi.list()) {
System.out.format(" %s%n", container.getName());
ObjectApi objectApi = cloudFilesApi.getObjectApi(region, container.getName());
ObjectList objects = objectApi.list();
for (SwiftObject object : objects) {
System.out.format(" %s%n", object.getName());
objectApi.delete(object.getName());
}
cloudFilesApi.getContainerApi(region).deleteIfEmpty(container.getName());
}
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
Closeables.close(cloudFilesApi, true);
}
示例7: listObjects
import org.jclouds.openstack.swift.v1.features.ObjectApi; //导入依赖的package包/类
private void listObjects() {
System.out.format("List Objects%n");
ObjectApi objectApi = cloudFiles.getObjectApi(REGION, CONTAINER);
ObjectList objects = objectApi.list();
for (SwiftObject object: objects) {
System.out.format(" %s%n", object);
}
}
示例8: listObjectsWithFiltering
import org.jclouds.openstack.swift.v1.features.ObjectApi; //导入依赖的package包/类
private void listObjectsWithFiltering() {
System.out.format("List Objects With Filtering%n");
ObjectApi objectApi = cloudFiles.getObjectApi(REGION, CONTAINER);
ListContainerOptions filter = ListContainerOptions.Builder.prefix("createObjectFromString");
ObjectList objects = objectApi.list(filter);
for (SwiftObject object: objects) {
System.out.format(" %s%n", object);
}
}
示例9: getObject
import org.jclouds.openstack.swift.v1.features.ObjectApi; //导入依赖的package包/类
private SwiftObject getObject() {
System.out.format("Get Object%n");
ObjectApi objectApi = cloudFiles.getObjectApi(REGION, CONTAINER);
SwiftObject swiftObject = objectApi.get("uploadObjectFromFile.txt");
System.out.format(" %s%n", swiftObject);
return swiftObject;
}