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


Java Blob.setPayload方法代码示例

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


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

示例1: getBlob

import org.jclouds.blobstore.domain.Blob; //导入方法依赖的package包/类
@Override
@Nullable
public Blob getBlob(String container, String name, GetOptions options) {
    Blob blob = super.getBlob(container, name, options);
    if (blob == null) {
        return null;
    }

    byte[] array;
    try (InputStream is = blob.getPayload().openStream()) {
        array = ByteStreams.toByteArray(is);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }

    long length = Longs.fromByteArray(array);
    ByteSourcePayload payload = new ByteSourcePayload(
            new NullByteSource().slice(0, length));
    payload.setContentMetadata(blob.getPayload().getContentMetadata());
    payload.getContentMetadata().setContentLength(length);
    payload.getContentMetadata().setContentMD5((HashCode) null);
    blob.setPayload(payload);
    return blob;
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:25,代码来源:NullBlobStore.java

示例2: putBlob

import org.jclouds.blobstore.domain.Blob; //导入方法依赖的package包/类
@Override
public String putBlob(String containerName, Blob blob,
        PutOptions options) {
    long length;
    try (InputStream is = blob.getPayload().openStream()) {
        length = ByteStreams.copy(is, ByteStreams.nullOutputStream());
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }

    byte[] array = Longs.toByteArray(length);
    ByteSourcePayload payload = new ByteSourcePayload(
            ByteSource.wrap(array));
    payload.setContentMetadata(blob.getPayload().getContentMetadata());
    payload.getContentMetadata().setContentLength((long) array.length);
    payload.getContentMetadata().setContentMD5((HashCode) null);
    blob.setPayload(payload);

    return super.putBlob(containerName, blob, options);
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:21,代码来源:NullBlobStore.java

示例3: upload

import org.jclouds.blobstore.domain.Blob; //导入方法依赖的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

示例4: pipeBlobAndReturn

import org.jclouds.blobstore.domain.Blob; //导入方法依赖的package包/类
private Blob pipeBlobAndReturn(String container, Blob blob) throws IOException {
    String name = blob.getMetadata().getName();
    logger.debug("piping {} from {} to {}", name, getDestStoreName(), getSourceStoreName());

    PipedInputStream pipeIn = new PipedInputStream();
    PipedOutputStream pipeOut = new PipedOutputStream(pipeIn);

    Payload blobPayload = blob.getPayload();
    MutableContentMetadata contentMetadata = blob.getMetadata().getContentMetadata();
    Blob retBlob = new BlobImpl(replaceSystemMetadata(blob.getMetadata()));
    retBlob.setPayload(pipeIn);
    retBlob.setAllHeaders(blob.getAllHeaders());
    TeeInputStream tee = new TeeInputStream(blobPayload.openStream(), pipeOut, true);
    retBlob.getMetadata().setContentMetadata(contentMetadata);

    app.executeBackgroundTask(() -> {
        try {
            logger.debug("copying {} to tee stream", name);
            return Utils.copyBlob(getDestination(), getSource(), container, blob, tee);
        } catch (RuntimeException e) {
            logger.error("copying " + name + " to tee stream failed", e);
            throw e;
        } finally {
            tee.close();
        }
    });
    return retBlob;
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:29,代码来源:WriteBackPolicy.java

示例5: replaceSystemMetadata

import org.jclouds.blobstore.domain.Blob; //导入方法依赖的package包/类
private Blob replaceSystemMetadata(Blob blob) {
    MutableContentMetadata contentMetadata = blob.getMetadata().getContentMetadata();
    Blob newBlob = new BlobImpl(replaceSystemMetadata(blob.getMetadata()));
    newBlob.setPayload(blob.getPayload());
    newBlob.setAllHeaders(blob.getAllHeaders());
    newBlob.getMetadata().setContentMetadata(contentMetadata);
    return newBlob;
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:9,代码来源:WriteBackPolicy.java


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