本文整理汇总了Java中org.jclouds.blobstore.domain.Blob.getMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java Blob.getMetadata方法的具体用法?Java Blob.getMetadata怎么用?Java Blob.getMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jclouds.blobstore.domain.Blob
的用法示例。
在下文中一共展示了Blob.getMetadata方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInputStream
import org.jclouds.blobstore.domain.Blob; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public InputStream getInputStream(String id, String root, String filePath) throws IOException {
ContainerAndName can = getContainerAndName(id, root, filePath);
Blob blob = getBlobStore().getBlob(can.container, can.name);
if (blob == null){
throw new IOException("No object found for " + id);
}
StorageMetadata metadata = blob.getMetadata();
Long size = metadata.getSize();
if (size != null && size.longValue() > maxBlobStreamSize) {
return streamFromTempFile(blob, size);
} else {
// SAK-30325: why can't we just send the stream straight back: blob.getPayload().openStream() ?
// Good question, but it doesn't work properly unless the stream is fully copied and re-streamed....
return new ByteArrayInputStream(FileCopyUtils.copyToByteArray(blob.getPayload().openStream()));
}
}
示例2: blobMetadata
import org.jclouds.blobstore.domain.Blob; //导入方法依赖的package包/类
@Override
@Nullable
public BlobMetadata blobMetadata(String container, String name) {
Blob blob = getBlob(container, name);
if (blob == null) {
return null;
}
return blob.getMetadata();
}
示例3: assertEqualBlobs
import org.jclouds.blobstore.domain.Blob; //导入方法依赖的package包/类
public static void assertEqualBlobs(Blob actual, Blob expected) throws Exception {
if (actual != expected) {
assertThat(actual).isNotNull();
assertThat(expected).isNotNull();
BlobMetadata actualMeta = actual.getMetadata();
BlobMetadata expectMeta = expected.getMetadata();
String name = expectMeta.getName();
ContentMetadata actualContentMeta = actualMeta.getContentMetadata();
ContentMetadata expectContentMeta = expectMeta.getContentMetadata();
if (actualContentMeta.getContentLength() < 100 && expectContentMeta.getContentLength() < 100) {
try (InputStream is = actual.getPayload().openStream();
InputStream is2 = expected.getPayload().openStream()) {
assertThat(is).as(name).hasContentEqualTo(is2);
}
}
// TODO: assert more metadata, including user metadata
// s3 doesn't return content md5
if (actualContentMeta.getContentMD5AsHashCode() != null &&
expectContentMeta.getContentMD5AsHashCode() != null) {
assertThat(actualContentMeta.getContentMD5AsHashCode()).as(name)
.isEqualTo(expectContentMeta.getContentMD5AsHashCode());
}
assertThat(actualContentMeta.getContentType()).as(name)
.isEqualTo(expectContentMeta.getContentType());
assertThat(actualContentMeta.getContentLength()).as(name)
.isEqualTo(expectContentMeta.getContentLength());
}
}