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

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

Introduction

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

Prototype

public String getContentEncoding() 

Source Link

Document

<p> Gets the optional Content-Encoding HTTP header specifying what content encodings have been applied to the object and what decoding mechanisms must be applied in order to obtain the media-type referenced by the Content-Type field.

Usage

From source file:org.openflamingo.fs.s3.S3Utils.java

License:Apache License

/**
 * Object  ./*from  ww w.ja v  a 2s.c  o  m*/
 *
 * @param client     Amazon S3 Client
 * @param bucketName Bucket Name
 */
public static Map<String, String> getDirectory(AmazonS3Client client, String bucketName, String objectKey) {
    S3Object object = client.getObject(bucketName, objectKey);
    ObjectMetadata objectMetadata = object.getObjectMetadata();

    List<FileInfo> filesList = new ArrayList<FileInfo>();
    ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(object.getBucketName())
            .withPrefix(objectKey).withDelimiter("/");

    ObjectListing objectListing = null;

    do {
        objectListing = client.listObjects(listObjectsRequest);
        List<String> commonPrefixes = objectListing.getCommonPrefixes();
        List<S3ObjectSummary> summary = objectListing.getObjectSummaries();
        listObjectsRequest.setMarker(objectListing.getNextMarker());
    } while (objectListing.isTruncated());

    Map<String, String> map = new HashMap<String, String>();

    map.put("bucketName", object.getBucketName());
    map.put("name", object.getKey());
    map.put("redirectionLocation", object.getRedirectLocation());

    setValue("version", objectMetadata.getVersionId(), map);
    setValue("contentDisposition", objectMetadata.getContentDisposition(), map);
    setValue("contentType", objectMetadata.getContentType(), map);
    setValue("etag", objectMetadata.getETag(), map);
    setValue("contentEncoding", objectMetadata.getContentEncoding(), map);
    setValue("contentLength", objectMetadata.getContentLength(), map);
    setValue("lastModified", objectMetadata.getLastModified(), map);
    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);/*  w ww .  j  a  v  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();
}