Examples of ObjectApi


Examples of org.jclouds.openstack.swift.v1.features.ObjectApi

      return getBlob(container, key, GetOptions.NONE);
   }

   @Override
   public Blob getBlob(String container, String name, GetOptions options) {
      ObjectApi objectApi = api.objectApiInRegionForContainer(region.getId(), container);
      SwiftObject object = objectApi.get(name, toGetOptions.apply(options));
      if (object == null) {
         return null;
      }
      Blob blob = new BlobImpl(toBlobMetadata(container).apply(object));
      blob.setPayload(object.getPayload());
View Full Code Here

Examples of org.jclouds.openstack.swift.v1.features.ObjectApi

      return list(container, ListContainerOptions.NONE);
   }

   @Override
   public PageSet<? extends StorageMetadata> list(final String container, ListContainerOptions options) {
      ObjectApi objectApi = api.getObjectApiForRegionAndContainer(regionId, container);
      ObjectList objects = objectApi.list(toListContainerOptions.apply(options));
      if (objects == null) {
         containerCache.put(container, Optional.<Container> absent());
         return new PageSetImpl<StorageMetadata>(ImmutableList.<StorageMetadata> of(), null);
      } else {
         containerCache.put(container, Optional.of(objects.getContainer()));
View Full Code Here

Examples of org.jclouds.openstack.swift.v1.features.ObjectApi

   @Override
   public String putBlob(String container, Blob blob, PutOptions options) {
      if (options.isMultipart()) {
         throw new UnsupportedOperationException();
      }
      ObjectApi objectApi = api.getObjectApiForRegionAndContainer(regionId, container);
      return objectApi.put(blob.getMetadata().getName(), blob.getPayload(), metadata(blob.getMetadata().getUserMetadata()));
   }
View Full Code Here

Examples of org.jclouds.openstack.swift.v1.features.ObjectApi

      return getBlob(container, key, GetOptions.NONE);
   }

   @Override
   public Blob getBlob(String container, String name, GetOptions options) {
      ObjectApi objectApi = api.getObjectApiForRegionAndContainer(regionId, container);
      SwiftObject object = objectApi.get(name, toGetOptions.apply(options));
      if (object == null) {
         return null;
      }
      Blob blob = new BlobImpl(toBlobMetadata(container).apply(object));
      blob.setPayload(object.getPayload());
View Full Code Here

Examples of org.jclouds.openstack.swift.v1.features.ObjectApi

   public void testPurgeObject() throws Exception {
      for (String regionId : regions) {
         String objectName = "testPurge";
         Payload payload = Payloads.newByteSourcePayload(ByteSource.wrap(new byte[] {1, 2, 3}));
         ObjectApi objectApi = api.getObjectApiForRegionAndContainer(regionId, name);
        
         // create a new object
         objectApi.put(objectName, payload);
        
         CDNApi cdnApi = api.getCDNApiForRegion(regionId);
         assertTrue(cdnApi.purgeObject(name, "testPurge", ImmutableList.<String>of()));
        
         // delete the object
         objectApi.delete(objectName);
         assertNull(objectApi.get(objectName, GetOptions.NONE));
      }
   }
View Full Code Here

Examples of org.jclouds.openstack.swift.v1.features.ObjectApi

   }

   private void getObject() {
      System.out.format("Get Object%n");

      ObjectApi objectApi = cloudFiles.getObjectApiForRegionAndContainer(REGION, CONTAINER);
      SwiftObject object = objectApi.get("uploadObjectFromFile.txt", GetOptions.NONE);

      System.out.format("  %s%n", object);
   }
View Full Code Here

Examples of org.jclouds.openstack.swift.v1.features.ObjectApi

      File tempFile = File.createTempFile(FILENAME, SUFFIX);

      try {
         Files.write("Hello Cloud Files", tempFile, Charsets.UTF_8);

         ObjectApi objectApi = cloudFiles.getObjectApiForRegionAndContainer(REGION, CONTAINER_PUBLISH);

         ByteSource byteSource = Files.asByteSource(tempFile);
         Payload payload = Payloads.newByteSourcePayload(byteSource);

         objectApi.put(FILENAME + SUFFIX, payload);
      } finally {
         tempFile.delete();
      }
   }
View Full Code Here

Examples of org.jclouds.openstack.swift.v1.features.ObjectApi

            .list(ListContainerOptions.Builder.prefix(CONTAINER)).toList();

      for (Container container: containers) {
         System.out.format("  %s%n", container.getName());

         ObjectApi objectApi = cloudFiles.getObjectApiForRegionAndContainer(REGION, container.getName());
         ObjectList objects = objectApi.list(ListContainerOptions.NONE);

         for (SwiftObject object: objects) {
            System.out.format("    %s%n", object.getName());
            objectApi.delete(object.getName());
         }

         cloudFiles.getContainerApiForRegion(REGION).deleteIfEmpty(container.getName());
      }
   }
View Full Code Here

Examples of org.jclouds.openstack.swift.v1.features.ObjectApi

   }

   private void listObjects() {
      System.out.format("List Objects%n");

      ObjectApi objectApi = cloudFiles.getObjectApiForRegionAndContainer(REGION, CONTAINER);
      ObjectList objects = objectApi.list(ListContainerOptions.NONE);

      for (SwiftObject object: objects) {
         System.out.format("  %s%n", object);
      }
   }
View Full Code Here

Examples of org.jclouds.openstack.swift.v1.features.ObjectApi

   }

   private void listObjectsWithFiltering() {
      System.out.format("List Objects With Filtering%n");

      ObjectApi objectApi = cloudFiles.getObjectApiForRegionAndContainer(REGION, CONTAINER);

      ListContainerOptions filter = ListContainerOptions.Builder.prefix("createObjectFromString");
      ObjectList objects =  objectApi.list(filter);

      for (SwiftObject object: objects) {
         System.out.format("  %s%n", object);
      }
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.