Example usage for com.amazonaws.services.s3.model PutObjectResult setContentMd5

List of usage examples for com.amazonaws.services.s3.model PutObjectResult setContentMd5

Introduction

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

Prototype

public void setContentMd5(String contentMd5) 

Source Link

Document

Sets the Base64-encoded MD5 hash of the object content that was calculated on the client-side.

Usage

From source file:eu.openg.aws.s3.internal.FakeBucketsContainer.java

License:Apache License

private PutObjectResult buildPutObjectResult(FakeS3Object object) {
    PutObjectResult result = new PutObjectResult();
    result.setETag(object.getETag());// www. jav a  2 s  .  c  o m
    result.setContentMd5(object.getMd5());
    return result;
}

From source file:org.elasticsearch.cloud.aws.blobstore.MockAmazonS3.java

License:Apache License

@Override
public PutObjectResult putObject(PutObjectRequest putObjectRequest)
        throws AmazonClientException, AmazonServiceException {
    String blobName = putObjectRequest.getKey();
    DigestInputStream stream = (DigestInputStream) putObjectRequest.getInputStream();

    if (blobs.containsKey(blobName)) {
        throw new AmazonS3Exception("[" + blobName + "] already exists.");
    }/*  www.ja va  2 s.  c o m*/

    blobs.put(blobName, stream);

    // input and output md5 hashes need to match to avoid an exception
    String md5 = Base64.encodeAsString(stream.getMessageDigest().digest());
    PutObjectResult result = new PutObjectResult();
    result.setContentMd5(md5);

    return result;
}