Example usage for com.amazonaws.services.s3.model ObjectMetadata getInstanceLength

List of usage examples for com.amazonaws.services.s3.model ObjectMetadata getInstanceLength

Introduction

In this page you can find the example usage for com.amazonaws.services.s3.model ObjectMetadata getInstanceLength.

Prototype

public long getInstanceLength() 

Source Link

Document

Returns the physical length of the entire object stored in S3.

Usage

From source file:org.nickelproject.nickel.blobStore.S3BlobStore.java

License:Apache License

@Override
public final InputStream getAsStream(final BlobRef blobRef) {
    final ObjectMetadata metaData = getMetadata(blobRef);
    if (metaData != null) {
        long start = 0;
        final List<ByteSource> byteSources = Lists.newArrayList();
        for (; start + downloadPartSize + 1 < metaData.getInstanceLength(); start += downloadPartSize + 1) {
            byteSources.add(new FutureByteSource(
                    executor.submit(new GetPartCallable(blobRef, start, start + downloadPartSize))));
        }/*  w  w  w . j a  va 2s . c om*/
        byteSources.add(new FutureByteSource(
                executor.submit(new GetPartCallable(blobRef, start, metaData.getInstanceLength() - 1))));
        try {
            return ByteSource.concat(byteSources).openStream();
        } catch (IOException e) {
            throw RethrownException.rethrow(e);
        }
    } else {
        return null;
    }
}

From source file:org.xmlsh.aws.util.AWSS3Command.java

License:BSD License

protected void writeMeta(ObjectMetadata m)
        throws InvalidArgumentException, XMLStreamException, SaxonApiException {

    mLogger.entry(m);/*from w  w  w . j  av  a2 s.  c  o  m*/
    startElement(sMetaDataElem);

    attribute("cache-control", m.getCacheControl());
    attribute("content-disposition", m.getContentDisposition());
    attribute("content-encoding", m.getContentEncoding());
    attribute("md5", m.getContentMD5());
    attribute("etag", m.getETag());
    attribute("version-id", m.getVersionId());
    attribute("content-length", String.valueOf(m.getContentLength()));
    attribute("last-modified", Util.formatXSDateTime(m.getLastModified()));
    attribute("expiration-time", Util.formatXSDateTime(m.getExpirationTime()));
    attribute("expiration-time-rule-id", m.getExpirationTimeRuleId());
    attribute("httpExpiresDate", Util.formatXSDateTime(m.getHttpExpiresDate()));
    attribute("ongoingRestore", m.getOngoingRestore());
    attribute("restore-expiration-time", Util.formatXSDateTime(m.getRestoreExpirationTime()));
    attribute("instance-length", m.getInstanceLength());
    attribute("sse-algorithm", m.getSSEAlgorithm());
    attribute("sse-aws-kms-key-id", m.getSSEAwsKmsKeyId());
    attribute("sse-customer-algorithm", m.getSSECustomerAlgorithm());
    attribute("sse-customer-key-md5", m.getSSECustomerKeyMd5());
    attribute("storage-class", m.getStorageClass());

    startElement("user-metadata");
    for (Entry<String, String> user : m.getUserMetadata().entrySet()) {
        startElement(sUserMetaDataElem);
        attribute("name", user.getKey());
        attribute("value", user.getValue());
        endElement();

    }
    endElement();
    endElement();

    mLogger.exit();
}