本文整理汇总了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;
}
示例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);
}
示例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";
}
示例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;
}
示例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;
}