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

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

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

BlobStore.copyBlob介绍

[英]Copy blob from one container to another. Some providers implement this more efficiently than corresponding getBlob and putBlob operations. Note: options are currently ignored
[中]将blob从一个容器复制到另一个容器。一些提供程序比相应的getBlob和putBlob操作更有效地实现这一点。注意:选项当前被忽略

代码示例

代码示例来源:origin: gaul/s3proxy

@Override
  public String call() {
    return delegate().copyBlob(fromContainer, fromName,
        toContainer, toName, options);
  }
});

代码示例来源:origin: gaul/s3proxy

@Override
public String copyBlob(final String fromContainer, final String fromName,
    final String toContainer, final String toName,
    final CopyOptions options) {
  String nearETag = writeStore.copyBlob(fromContainer, fromName,
      toContainer, toName, options);
  schedule(new Callable<String>() {
      @Override
      public String call() {
        return delegate().copyBlob(fromContainer, fromName,
            toContainer, toName, options);
      }
    });
  return nearETag;
}

代码示例来源:origin: gaul/s3proxy

eTag = blobStore.copyBlob(
    sourceContainerName, sourceBlobName,
    destContainerName, destBlobName, options.build());

代码示例来源:origin: org.gaul/s3proxy

@Override
  public String call() {
    return delegate().copyBlob(fromContainer, fromName,
        toContainer, toName, options);
  }
});

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

@Override
  public String call() {
    return delegate().copyBlob(fromContainer, fromName,
        toContainer, toName, options);
  }
});

代码示例来源:origin: bouncestorage/swiftproxy

private String serverCopyBlob(BlobStore blobStore, String container, String objectName, String destContainer,
               String destObject, CopyOptions options) {
  try {
    return blobStore.copyBlob(container, objectName, destContainer, destObject, options);
  } catch (RuntimeException e) {
    if (e.getCause() instanceof HttpResponseException) {
      throw (HttpResponseException) e.getCause();
    } else {
      throw e;
    }
  }
}

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

@Override
public String copyBlob(String fromContainer, String fromName, String toContainer, String toName,
   CopyOptions options) {
 return delegate().copyBlob(fromContainer, fromName, toContainer, toName, options);
}

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

@Override
public String copyBlob(String fromContainer, String fromName, String toContainer, String toName,
   CopyOptions options) {
 return delegate().copyBlob(fromContainer, fromName, toContainer, toName, options);
}

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

@Override
public String copyBlob(String fromContainer, String fromName, String toContainer, String toName,
   CopyOptions options) {
 return delegate().copyBlob(fromContainer, fromName, toContainer, toName, options);
}

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

@Override
public String copyBlob(String fromContainer, String fromName, String toContainer, String toName,
   CopyOptions options) {
 return delegate().copyBlob(fromContainer, fromName, toContainer, toName, options);
}

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

@Override
public String copyBlob(final String fromContainer, final String fromName,
    final String toContainer, final String toName,
    final CopyOptions options) {
  String nearETag = writeStore.copyBlob(fromContainer, fromName,
      toContainer, toName, options);
  schedule(new Callable<String>() {
      @Override
      public String call() {
        return delegate().copyBlob(fromContainer, fromName,
            toContainer, toName, options);
      }
    });
  return nearETag;
}

代码示例来源:origin: org.gaul/s3proxy

@Override
public String copyBlob(final String fromContainer, final String fromName,
    final String toContainer, final String toName,
    final CopyOptions options) {
  String nearETag = writeStore.copyBlob(fromContainer, fromName,
      toContainer, toName, options);
  schedule(new Callable<String>() {
      @Override
      public String call() {
        return delegate().copyBlob(fromContainer, fromName,
            toContainer, toName, options);
      }
    });
  return nearETag;
}

代码示例来源:origin: opendedup/sdfs

@Override
public void renameFile(String from, String to, String pp) throws IOException {
  while (from.startsWith(File.separator))
    from = from.substring(1);
  while (to.startsWith(File.separator))
    to = to.substring(1);
  String fn = EncyptUtils.encString(from, Main.chunkStoreEncryptionEnabled);
  String tn = EncyptUtils.encString(to, Main.chunkStoreEncryptionEnabled);
  try {
    blobStore.copyBlob(this.name, fn, this.name, tn,
        CopyOptions.builder().userMetadata(this.getUserMetaData(fn)).build());
  } catch (Exception e) {
    throw new IOException(e);
  }
}

代码示例来源:origin: org.apache.james/blob-objectstorage

private void updateBlobId(BlobId from, BlobId to) {
  String containerName = this.containerName.value();
  blobStore.copyBlob(containerName, from.asString(), containerName, to.asString(),
    CopyOptions.NONE);
  blobStore.removeBlob(containerName, from.asString());
}

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

@Test(groups = { "integration", "live" }, expectedExceptions = {KeyNotFoundException.class})
public void testCopy404BlobFail() throws Exception {
 BlobStore blobStore = view.getBlobStore();
 String container = getContainerName();
 try {
   blobStore.copyBlob(container, "blob", container, "blob2", CopyOptions.NONE);
 } finally {
   returnContainer(container);
 }
}

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

@Test(groups = { "integration", "live" }, expectedExceptions = {KeyNotFoundException.class})
public void testCopy404BlobMetaFail() throws Exception {
 BlobStore blobStore = view.getBlobStore();
 String container = getContainerName();
 try {
   blobStore.copyBlob(container, "blob", container, "blob2",
      CopyOptions.builder().userMetadata(ImmutableMap.of("x", "1")).build());
 } finally {
   returnContainer(container);
 }
}

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

assertConsistencyAwareContainerSize(containerName, 1);
view.getBlobStore().copyBlob(
  containerName, blobName, containerName, blobName,
  CopyOptions.builder().userMetadata(ImmutableMap.of("B", "b", "a", "a")).build()

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

@Test(groups = { "integration", "live" })
public void testCopyIfModifiedSinceNegative() throws Exception {
 BlobStore blobStore = view.getBlobStore();
 String fromName = "source";
 String toName = "to";
 ByteSource payload = TestUtils.randomByteSource().slice(0, 1024);
 Blob blob = blobStore
    .blobBuilder(fromName)
    .payload(payload)
    .contentLength(payload.size())
    .build();
 String fromContainer = getContainerName();
 String toContainer = getContainerName();
 try {
   blobStore.putBlob(fromContainer, blob);
   // TODO: some problem with S3 and times in the future?
   Date after = new Date(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1));
   try {
    blobStore.copyBlob(fromContainer, fromName, toContainer, toName, CopyOptions.builder().ifModifiedSince(after).build());
    Fail.failBecauseExceptionWasNotThrown(HttpResponseException.class);
   } catch (HttpResponseException hre) {
    // most object stores return 412 but swift returns 304
    assertThat(hre.getResponse().getStatusCode()).isIn(304, 412);
   }
 } finally {
   returnContainer(toContainer);
   returnContainer(fromContainer);
 }
}

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

@Test(groups = { "integration", "live" })
public void testCopyIfMatchNegative() throws Exception {
 BlobStore blobStore = view.getBlobStore();
 String fromName = "source";
 String toName = "to";
 ByteSource payload = TestUtils.randomByteSource().slice(0, 1024);
 Blob blob = blobStore
    .blobBuilder(fromName)
    .payload(payload)
    .contentLength(payload.size())
    .build();
 String fromContainer = getContainerName();
 String toContainer = getContainerName();
 try {
   blobStore.putBlob(fromContainer, blob);
   try {
    blobStore.copyBlob(fromContainer, fromName, toContainer, toName, CopyOptions.builder().ifMatch("fake-etag").build());
    Fail.failBecauseExceptionWasNotThrown(HttpResponseException.class);
   } catch (HttpResponseException hre) {
    assertThat(hre.getResponse().getStatusCode()).isEqualTo(412);
   }
 } finally {
   returnContainer(toContainer);
   returnContainer(fromContainer);
 }
}

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

@Test(groups = { "integration", "live" })
public void testCopyIfNoneMatch() throws Exception {
 BlobStore blobStore = view.getBlobStore();
 String fromName = "source";
 String toName = "to";
 ByteSource payload = TestUtils.randomByteSource().slice(0, 1024);
 Blob blob = blobStore
    .blobBuilder(fromName)
    .payload(payload)
    .contentLength(payload.size())
    .build();
 String fromContainer = getContainerName();
 String toContainer = getContainerName();
 try {
   blobStore.putBlob(fromContainer, blob);
   blobStore.copyBlob(fromContainer, fromName, toContainer, toName, CopyOptions.builder().ifNoneMatch("fake-etag").build());
   Blob toBlob = blobStore.getBlob(toContainer, toName);
   InputStream is = null;
   try {
    is = toBlob.getPayload().openStream();
    assertEquals(ByteStreams.toByteArray(is), payload.read());
   } finally {
    Closeables2.closeQuietly(is);
   }
 } finally {
   returnContainer(toContainer);
   returnContainer(fromContainer);
 }
}

相关文章