org.jclouds.blobstore.BlobStore.createDirectory()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(201)

本文整理了Java中org.jclouds.blobstore.BlobStore.createDirectory()方法的一些代码示例,展示了BlobStore.createDirectory()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BlobStore.createDirectory()方法的具体详情如下:
包路径:org.jclouds.blobstore.BlobStore
类名称:BlobStore
方法名:createDirectory

BlobStore.createDirectory介绍

[英]Creates a folder or a directory marker depending on the service
[中]根据服务创建文件夹或目录标记

代码示例

代码示例来源:origin: org.apache.camel/camel-jclouds

/**
 * Creates all directories that are part of the blobName.
 */
public static void mkDirs(BlobStore blobStore, String container, String blobName) {
  if (blobStore != null && !Strings.isNullOrEmpty(blobName) && blobName.contains("/")) {
    String directory = BlobStoreUtils.parseDirectoryFromPath(blobName);
    blobStore.createDirectory(container, directory);
  }
}

代码示例来源:origin: com.amysta.jclouds/jclouds-blobstore

@Override
public void createDirectory(String container, String directory) {
 delegate().createDirectory(container, directory);
}

代码示例来源:origin: Nextdoor/bender

@Override
public void createDirectory(String container, String directory) {
 delegate().createDirectory(container, directory);
}

代码示例来源:origin: org.apache.jclouds/jclouds-blobstore

@Override
public void createDirectory(String container, String directory) {
 delegate().createDirectory(container, directory);
}

代码示例来源:origin: apache/jclouds

@Override
public void createDirectory(String container, String directory) {
 delegate().createDirectory(container, directory);
}

代码示例来源:origin: org.apache.jclouds.karaf/commands

/**
* Writes to the {@link org.jclouds.blobstore.domain.Blob} using an InputStream.
* 
* @param blobStore
* @param bucket
* @param blobName
* @param blob
* @param options
*/
public void write(BlobStore blobStore, String bucket, String blobName, Blob blob, PutOptions options, boolean signedRequest) throws Exception {
 if (blobName.contains("/")) {
   String directory = BlobStoreUtils.parseDirectoryFromPath(blobName);
   if (!Strings.isNullOrEmpty(directory)) {
    blobStore.createDirectory(bucket, directory);
   }
 }
 if (signedRequest) {
   BlobStoreContext context = blobStore.getContext();
   HttpRequest request = context.getSigner().signPutBlob(bucket, blob);
   HttpClient httpClient = context.utils().http();
   HttpResponse response = httpClient.invoke(request);
   int statusCode = response.getStatusCode();
   if (statusCode != 200 && statusCode != 201) {
    throw new IOException(response.getStatusLine());
   }
 } else {
   blobStore.putBlob(bucket, blob, options);
 }
}

代码示例来源:origin: apache/jclouds

public void testDirectoryListing() {
   String containerName = "testDirectoryListing";
   blobStore.createContainerInLocation(null, containerName);
   blobStore.createDirectory(containerName, "dir");
   blobStore.createDirectory(containerName, "dir/dir");

   PageSet<? extends StorageMetadata> results = blobStore.list(containerName);
   assertThat(results.size()).isEqualTo(2);
   assertThat(Iterables.get(results, 0).getName()).isEqualTo("dir");
   assertThat(Iterables.get(results, 1).getName()).isEqualTo("dir/");

   results = blobStore.list(containerName, ListContainerOptions.Builder.inDirectory("dir"));
   assertThat(results.size()).isEqualTo(1);
   assertThat(Iterables.get(results, 0).getName()).isEqualTo("dir/dir");
   assertThat(Iterables.get(results, 0).getType()).isEqualTo(StorageType.FOLDER);

   blobStore.putBlob(containerName, blobStore.blobBuilder("dir/dir/blob").payload("").build());
   results = blobStore.list(containerName, ListContainerOptions.Builder.inDirectory("dir"));
   assertThat(results.size()).isEqualTo(2);
   assertThat(Iterables.get(results, 0).getName()).isEqualTo("dir/dir");
   assertThat(Iterables.get(results, 0).getType()).isEqualTo(StorageType.FOLDER);
   assertThat(Iterables.get(results, 1).getName()).isEqualTo("dir/dir/");
   assertThat(Iterables.get(results, 1).getType()).isEqualTo(StorageType.RELATIVE_PATH);
  }
}

代码示例来源:origin: jclouds/legacy-jclouds

try {
  view.getBlobStore().createDirectory(containerName, directory);
  addTenObjectsUnderRoot(containerName);
  assertEquals(rootMap.size(), 10);
     ImmutableSortedSet.of("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
  view.getBlobStore().createDirectory(containerName, directory + "/" + directory);
  assertEquals(rootMap.size(), 10);
  assertEquals(rootRecursiveMap.size(), 20);

代码示例来源:origin: apache/jclouds

public void testListDirectory() {
 String containerName = "testListDir";
 String directory = "dir";
 blobStore.createContainerInLocation(null, containerName);
 blobStore.createDirectory(containerName, directory);
 blobStore.putBlob(containerName, blobStore.blobBuilder(directory + "/foo").payload("").build());
 blobStore.putBlob(containerName, blobStore.blobBuilder(directory + "/bar").payload("").build());
 Iterable<? extends StorageMetadata> results = concatter.execute(containerName, ListContainerOptions.NONE);
 assertThat(results).hasSize(2);
 assertThat(Iterables.get(results, 0).getName()).isEqualTo(directory);
 assertThat(Iterables.get(results, 0).getType()).isEqualTo(StorageType.FOLDER);
 assertThat(Iterables.get(results, 1).getName()).isEqualTo(directory + '/');
 assertThat(Iterables.get(results, 1).getType()).isEqualTo(StorageType.RELATIVE_PATH);
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testDirectoryEndingWithSlash() throws InterruptedException {
    String containerName = getContainerName();
    try {
      BlobStore blobStore = view.getBlobStore();
      blobStore.createDirectory(containerName, "someDir");

      // According to the S3 documentation, a directory is nothing but a blob
      // whose name ends with a '/'. So let's try to remove the blob we just
      // created.
      blobStore.removeBlob(containerName, "someDir/");

      // The directory "someDir" shouldn't exist since we removed it. If this
      // test succeeds, it confirms that a directory (or folder) is nothing
      // but a blob with a name ending in '/'.
      assertEquals(blobStore.directoryExists(containerName, "someDir"), false);
    } finally {
      returnContainer(containerName);
    }
  }
}

代码示例来源:origin: apache/jclouds

public void testDirectoryEndingWithSlash() throws InterruptedException {
  String containerName = getContainerName();
  try {
    BlobStore blobStore = view.getBlobStore();
    blobStore.createDirectory(containerName, "someDir");
    // According to the S3 documentation, a directory is nothing but a blob
    // whose name ends with a '/'. So let's try to remove the blob we just
    // created.
    blobStore.removeBlob(containerName, "someDir/");
    // The directory "someDir" shouldn't exist since we removed it. If this
    // test succeeds, it confirms that a directory (or folder) is nothing
    // but a blob with a name ending in '/'.
    assertEquals(blobStore.directoryExists(containerName, "someDir"), false);
  } finally {
    returnContainer(containerName);
  }
}

代码示例来源:origin: com.googlecode.the-fascinator.plugins/plugin-storage-blobstore

/**
 * Create a new object in storage. An object identifier may be provided, or
 * a null value will try to have Fedora auto-generate the new OID.
 *
 * @param oid
 *            the Object ID to use during creation, null is allowed
 * @return DigitalObject the instantiated DigitalObject created
 * @throws StorageException
 *             if any errors occur
 */
@Override
public synchronized DigitalObject createObject(String oid) throws StorageException {
  // log.debug("createObject({})", oid);
  if (oid == null) {
    throw new StorageException("Error; Null OID recieved");
  }
  // Can we see object?
  if (BlobStoreClient.getClient().directoryExists(BlobStoreClient.getContainerName(), oid)) {
    throw new StorageException("Error; object '" + oid + "' already exists in Blobstore");
  }
  BlobStoreClient.getClient().createDirectory(BlobStoreClient.getContainerName(), oid);
  // Instantiate and return
  return new BlobStoreDigitalObject(oid);
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-locations-jclouds

public void testCreateListDestroySimpleDirInContainer() throws IOException {
  context.getBlobStore().createContainerInLocation(null, testContainerName);
  context.getBlobStore().createDirectory(testContainerName, "my-dir-1");
  
  PageSet<? extends StorageMetadata> ps = context.getBlobStore().list(testContainerName);
  assertHasItemNamed(ps, "my-dir-1");
  
  Blob b = context.getBlobStore().blobBuilder("my-blob-1").payload(Streams.newInputStreamWithContents("hello world")).build();
  context.getBlobStore().putBlob(testContainerName+"/"+"my-dir-1", b);
  
  ps = context.getBlobStore().list(testContainerName, ListContainerOptions.Builder.inDirectory("my-dir-1"));
  assertHasItemNamed(ps, "my-dir-1/my-blob-1");
  // both these syntaxes work:
  Blob b2 = context.getBlobStore().getBlob(testContainerName+"/"+"my-dir-1", "my-blob-1");
  Assert.assertEquals(Streams.readFullyStringAndClose(b2.getPayload().openStream()), "hello world");
  Blob b3 = context.getBlobStore().getBlob(testContainerName, "my-dir-1"+"/"+"my-blob-1");
  Assert.assertEquals(Streams.readFullyStringAndClose(b3.getPayload().openStream()), "hello world");
  context.getBlobStore().deleteContainer(testContainerName);
}

代码示例来源:origin: apache/jclouds

view.getBlobStore().createDirectory(containerName, directory);
view.getBlobStore().createDirectory(containerName, directory + "/" + directory);
assertThat(container).hasSize(0);
view.getBlobStore().createDirectory(containerName, directory + "/" + directory);

代码示例来源:origin: jclouds/legacy-jclouds

view.getBlobStore().createDirectory(containerName, directory);
view.getBlobStore().createDirectory(containerName, directory + "/" + directory);
assert view.getBlobStore().directoryExists(containerName, directory + "/" + directory);
assert container.size() == 1 : container;
view.getBlobStore().createDirectory(containerName, directory + "/" + directory);

相关文章