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


Java BlobStore.putBlob方法代码示例

本文整理汇总了Java中org.jclouds.blobstore.BlobStore.putBlob方法的典型用法代码示例。如果您正苦于以下问题:Java BlobStore.putBlob方法的具体用法?Java BlobStore.putBlob怎么用?Java BlobStore.putBlob使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jclouds.blobstore.BlobStore的用法示例。


在下文中一共展示了BlobStore.putBlob方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerAddress

import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
private void registerAddress(String cluster, InetSocketAddress address) throws HekateException {
    try (BlobStoreContext ctx = createContext()) {
        BlobStore store = ctx.getBlobStore();

        String file = cluster + '/' + AddressUtils.toFileName(address);

        try {
            if (!store.blobExists(container, file)) {
                Blob blob = store.blobBuilder(file)
                    .type(StorageType.BLOB)
                    .payload(new byte[]{1})
                    .build();

                store.putBlob(container, blob);

                if (log.isInfoEnabled()) {
                    log.info("Registered address to the cloud store [container={}, file={}]", container, file);
                }
            }
        } catch (ResourceNotFoundException | HttpResponseException e) {
            throw new HekateException("Failed to register the seed node address to the cloud store "
                + "[container=" + container + ", file=" + file + ']', e);
        }
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:26,代码来源:CloudStoreSeedNodeProvider.java

示例2: emulateCopyBlob

import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
private String emulateCopyBlob(BlobStore blobStore, Response resp, BlobMetadata meta,
                               String destContainer, String destObject, CopyOptions options) {
    Response.StatusType statusInfo = resp.getStatusInfo();
    if (statusInfo.equals(Response.Status.OK)) {
        ContentMetadata contentMetadata = meta.getContentMetadata();
        Map<String, String> newMetadata = new HashMap<>();
        newMetadata.putAll(meta.getUserMetadata());
        newMetadata.putAll(options.userMetadata());
        RESERVED_METADATA.forEach(s -> newMetadata.remove(s));
        Blob blob = blobStore.blobBuilder(destObject)
                .userMetadata(newMetadata)
                .payload(new InputStreamPayload((InputStream) resp.getEntity()))
                .contentLength(resp.getLength())
                .contentDisposition(contentMetadata.getContentDisposition())
                .contentEncoding(contentMetadata.getContentEncoding())
                .contentType(contentMetadata.getContentType())
                .contentLanguage(contentMetadata.getContentLanguage())
                .build();
        return blobStore.putBlob(destContainer, blob);
    } else {
        throw new ClientErrorException(statusInfo.getReasonPhrase(), statusInfo.getStatusCode());
    }

}
 
开发者ID:bouncestorage,项目名称:swiftproxy,代码行数:25,代码来源:ObjectResource.java

示例3: moveFile

import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
/**
 * Move a file from one AWS S3 folder to another.
 *
 * @param blobStore         the blob store
 * @param sourceKey         the file source location
 * @param destinationFolder the destination folder
 * @return the destination key of the moved file
 * @throws KeyNotFoundException if a key is not found
 */
@GuardedBy("ThreadLocal blobStore")
private String moveFile(final BlobStore blobStore, final String sourceKey,
                        final String destinationFolder) throws KeyNotFoundException {

  final Blob blob = blobStore.getBlob(config.getS3().getBucket(), sourceKey);

  if (blob != null) {

    final String destinationKey = destinationFolder + "/"
        + sourceKey.substring(sourceKey.lastIndexOf('/') + 1);

    blob.getMetadata().setName(destinationKey);
    blobStore.putBlob(config.getS3().getBucket(), blob);
    blobStore.removeBlob(config.getS3().getBucket(), sourceKey);
    return destinationKey;

  } else {
    throw new KeyNotFoundException(sourceKey, config.getS3().getBucket(), "Error while moving file.");
  }
}
 
开发者ID:Pixxis,项目名称:zoufzouf,代码行数:30,代码来源:LogSlurper.java

示例4: copyBlob

import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
public static Blob copyBlob(BlobStore from, BlobStore to, String containerNameTo, Blob blobFrom, InputStream is)
    throws IOException {
    if (blobFrom == null || BounceLink.isLink(blobFrom.getMetadata())) {
        return null;
    }
    ContentMetadata metadata = blobFrom.getMetadata().getContentMetadata();
    PayloadBlobBuilder builder = to.blobBuilder(blobFrom.getMetadata().getName())
            .userMetadata(blobFrom.getMetadata().getUserMetadata())
            .payload(is);

    copyToBlobBuilder(metadata, builder);

    if (isSwiftBlobStore(to)) {
        copySwiftBlob(from, to, containerNameTo, builder.build());
    } else {
        to.putBlob(containerNameTo, builder.build(), MULTIPART_PUT);
    }
    return blobFrom;
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:20,代码来源:Utils.java

示例5: testListThreeTiers

import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
@Test
public void testListThreeTiers() throws Exception {
    BlobStore blobStore = app.getBlobStore(0);
    String cacheBlobName = UtilsTest.createRandomBlobName();
    Blob cacheBlob = UtilsTest.makeBlob(blobStore, cacheBlobName);
    blobStore.putBlob(containerName, cacheBlob);
    BounceService.BounceTaskStatus status = bounceService.bounce(containerName);
    status.future().get();
    assertStatus(status, status::getCopiedObjectCount).isEqualTo(2);

    StorageMetadata metadata = policy.list(containerName).iterator().next();
    assertThat(metadata).isInstanceOf(BounceStorageMetadata.class);
    assertThat(((BounceStorageMetadata) metadata).getRegions()).isEqualTo(ImmutableSet.of(
            BounceStorageMetadata.Region.FAR,
            BounceStorageMetadata.Region.NEAR,
            BounceStorageMetadata.Region.FARTHER));
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:18,代码来源:ThreeTierWriteBackPolicyTest.java

示例6: testListContainer

import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
@Test
public void testListContainer() throws Exception {
    String containerName = Utils.createRandomContainerName();
    String blobName = UtilsTest.createRandomBlobName();
    BlobStore blobStore = app.getBlobStore(objectStoreId);
    blobStore.createContainerInLocation(null, containerName);
    Blob blob = UtilsTest.makeBlob(blobStore, blobName);
    blobStore.putBlob(containerName, blob);

    HttpURLConnection connection = UtilsTest.submitRequest(containerAPI + "/" + containerName,
            HttpMethod.GET, null);
    assertThat(connection.getResponseCode()).isEqualTo(Response.Status.OK.getStatusCode());
    try (InputStream stream = connection.getInputStream()) {
        ContainerResource.Container container = new ObjectMapper().readValue(stream,
                ContainerResource.Container.class);
        assertThat(container.objects).hasSize(1);
        assertThat(container.objects.get(0).name).isEqualTo(blobName);
    }
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:20,代码来源:ContainerResourceTest.java

示例7: testRecursiveList

import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
@Test
public void testRecursiveList() throws Exception {
    String container = Utils.createRandomContainerName();
    BlobStore blobStore = app.getBlobStore(objectStoreId);
    blobStore.createContainerInLocation(null, container);
    String blob = "foo/bar";
    String blob2 = "foo/baz";
    blobStore.putBlob(container, UtilsTest.makeBlob(blobStore, blob));
    blobStore.putBlob(container, UtilsTest.makeBlob(blobStore, blob2));
    HttpURLConnection connection = UtilsTest.submitRequest(containerAPI + "/" + container, HttpMethod.GET, null);
    assertThat(connection.getResponseCode()).isEqualTo(Response.Status.OK.getStatusCode());
    try (InputStream stream = connection.getInputStream()) {
        ContainerResource.Container resultContainer = new ObjectMapper().readValue(stream,
                ContainerResource.Container.class);
        assertThat(resultContainer.objects).hasSize(2);
        assertThat(resultContainer.objects.get(0).name).isEqualTo(blob);
        assertThat(resultContainer.objects.get(1).name).isEqualTo(blob2);
    }
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:20,代码来源:ContainerResourceTest.java

示例8: testConfigMoveEverythingPolicy

import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
@Test
public void testConfigMoveEverythingPolicy() throws Exception {
    setTransientBackend();
    app.getBlobStore(0).createContainerInLocation(null, containerName);
    app.getBlobStore(1).createContainerInLocation(null, containerName);

    BlobStore blobStore = app.getBlobStore(0);
    blobStore.createContainerInLocation(null, containerName);

    blobStore.putBlob(containerName,
            UtilsTest.makeBlob(blobStore, UtilsTest.createRandomBlobName()));

    configureMoveEverythingPolicy();
    blobStore = app.getBlobStore(containerName);
    blobStore.createContainerInLocation(null, containerName);

    BounceService.BounceTaskStatus status = bounceService.bounce(containerName);
    status.future().get();
    assertStatus(status, status::getTotalObjectCount).isEqualTo(1);
    assertStatus(status, status::getMovedObjectCount).isEqualTo(1);
    assertStatus(status, status::getErrorObjectCount).isEqualTo(0);
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:23,代码来源:ConfigTest.java

示例9: createRawContent

import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
/**
	 * As {@link #createRawContent(String, byte[])} except sets {@link BlobAccess} for the path also
	 * @param contentPath
	 * @param access
	 * @param content
	 */
	public final void createRawContent(String contentPath, BlobAccess access, byte[] content) {
//		contentPaths.add(contentPath);
		BlobStore blobStore = blobStoreContext.getBlobStore();
		Blob blob = blobStore.blobBuilder(contentPath)
			    .payload(content)
			    .contentLength(content.length)
			    .contentType(MediaType.OCTET_STREAM.toString())
			    .build();
		blobStore.putBlob(CONTAINER_NAME, blob);
		
		if (access != null) {
			blobStore.setBlobAccess(CONTAINER_NAME, contentPath, access);
		}
	}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:21,代码来源:AbstractJCloudsIntegrationTest.java

示例10: writeBlob

import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
/**
 * Writes {@link Payload} to the the {@link BlobStore}.
 */
public static void writeBlob(BlobStore blobStore, String container, String blobName, Payload payload) {
    if (blobName != null && payload != null) {
        mkDirs(blobStore, container, blobName);
        Blob blob = blobStore.blobBuilder(blobName).payload(payload).contentType(MediaType.APPLICATION_OCTET_STREAM).contentDisposition(blobName).build();
        blobStore.putBlob(container, blob, multipart());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:JcloudsBlobStoreHelper.java

示例11: upload

import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
@Override
public String upload(InputStream content, Blob blob) throws IOException {
    BlobStore blobStore = this.blobStoreContext.getBlobStore();
    blob.setPayload(content);
    blobStore.putBlob(containerName, blob);
    return "etag";
}
 
开发者ID:orange-cloudfoundry,项目名称:db-dumper-service,代码行数:8,代码来源:UploadS3StreamFake.java

示例12: saveInputStream

import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
    public long saveInputStream(String id, String root, String filePath, InputStream stream) throws IOException {
        if(stream == null){
            return 0L;
        }
        ContainerAndName can = getContainerAndName(id, root, filePath);
        createContainerIfNotExist(can.container);

        InputStream in = markableInputStream(stream);
        long size = markableStreamLength(in);

        Payload payload = Payloads.newInputStreamPayload(in);

        try {
            BlobStore store = getBlobStore();
            String asciiID = Base64.encodeBase64String(id.getBytes("UTF8"));

            Blob blob = store.blobBuilder(can.name)
                .payload(payload)
                .contentLength(size)
                .userMetadata(ImmutableMap.of("id", asciiID, "path", filePath))
                .build();
            store.putBlob(can.container, blob);
        } finally {
            payload.release();
            Closeables.close(stream, true);
            Closeables.close(in, true);
        }

        return size;
    }
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:35,代码来源:BlobStoreFileSystemHandler.java

示例13: putMetadataBlob

import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
public static String putMetadataBlob(Map<String, String> metadata, BlobStore blobStore, String vault,
                                     String archiveName) {
    Gson gson = new Gson();
    String jsonString = gson.toJson(metadata);
    Blob metadataBlob = blobStore.blobBuilder(getMetadataBlobName(archiveName))
            .payload(ByteSource.wrap(jsonString.getBytes())).build();
    return blobStore.putBlob(vault, metadataBlob);
}
 
开发者ID:bouncestorage,项目名称:glacier-proxy,代码行数:9,代码来源:Util.java

示例14: copySwiftBlob

import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
private static void copySwiftBlob(BlobStore from, BlobStore to, String containerNameTo, Blob blob) {
    // TODO: swift object semantic changes if we do multipart upload,
    // if both sides are swift, we may want to just copy the individual parts
    PutOptions options = PutOptions.NONE;
    if (blob.getMetadata().getContentMetadata().getContentLength() > to.getMaximumMultipartPartSize()) {
        options = MULTIPART_PUT;
    }
    to.putBlob(containerNameTo, blob, options);
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:10,代码来源:Utils.java

示例15: uploadSourceBlob

import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
private void uploadSourceBlob() {
    BlobStore blobStore = app.getBlobStore(0);
    String blobName = UtilsTest.createRandomBlobName();
    byte[] blobContent = "foo".getBytes();
    blob = UtilsTest.makeBlob(blobStore, blobName, ByteSource.wrap(blobContent));
    blobStore.createContainerInLocation(null, container);
    blobStore.putBlob(container, blob);
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:9,代码来源:BounceStatsTest.java


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