Example usage for com.amazonaws.services.s3.model CopyObjectRequest withMetadataDirective

List of usage examples for com.amazonaws.services.s3.model CopyObjectRequest withMetadataDirective

Introduction

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

Prototype

public CopyObjectRequest withMetadataDirective(MetadataDirective metadataDirective) 

Source Link

Document

Specifies whether the metadata is copied from the source object or replaced with metadata provided in the request.

Usage

From source file:io.minio.awssdk.tests.S3TestUtils.java

License:Apache License

void copyObject(String bucketName, String keyName, SSECustomerKey sseKey, String targetBucketName,
        String targetKeyName, SSECustomerKey newSseKey, boolean replace) {
    CopyObjectRequest copyRequest = new CopyObjectRequest(bucketName, keyName, targetBucketName, targetKeyName);
    if (sseKey != null) {
        copyRequest.withSourceSSECustomerKey(sseKey);
    }/* w  w  w .  ja v  a2s .  c o  m*/
    if (newSseKey != null) {
        copyRequest.withDestinationSSECustomerKey(newSseKey);
    }
    if (replace) {
        copyRequest.withMetadataDirective(MetadataDirective.COPY);
    }
    s3Client.copyObject(copyRequest);
}