当前位置: 首页>>代码示例>>Java>>正文


Java ObjectApi类代码示例

本文整理汇总了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());
   }
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:24,代码来源:DeleteObjectsAndContainer.java

示例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();
   }
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:22,代码来源:CloudFilesPublish.java

示例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();
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:15,代码来源:SwiftFileSystemHandler.java

示例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()));
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:16,代码来源:SwiftFileSystemHandler.java

示例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;
    }
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:16,代码来源:SwiftFileSystemHandler.java

示例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);
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:31,代码来源:DeleteAll.java

示例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);
   }
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:11,代码来源:ListObjects.java

示例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);
   }
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:13,代码来源:ListObjects.java

示例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;
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:11,代码来源:GetObject.java


注:本文中的org.jclouds.openstack.swift.v1.features.ObjectApi类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。