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


Java Blob.getMetadata方法代码示例

本文整理汇总了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()));
    }
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:23,代码来源:BlobStoreFileSystemHandler.java

示例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();
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:10,代码来源:NullBlobStore.java

示例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());
    }
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:30,代码来源:UtilsTest.java


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