Example usage for com.amazonaws.services.dynamodbv2.model PutItemRequest addItemEntry

List of usage examples for com.amazonaws.services.dynamodbv2.model PutItemRequest addItemEntry

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.model PutItemRequest addItemEntry.

Prototype

public PutItemRequest addItemEntry(String key, AttributeValue value) 

Source Link

Usage

From source file:awslabs.lab51.SolutionCode.java

License:Open Source License

@Override
public void addImage(AmazonDynamoDBClient dynamoDbClient, String tableName, AmazonS3Client s3Client,
        String bucketName, String imageKey, String filePath) {

    try {/* w w w  .  jav  a2 s . c  o m*/
        File file = new File(filePath);
        if (file.exists()) {
            s3Client.putObject(bucketName, imageKey, file);

            PutItemRequest putItemRequest = new PutItemRequest().withTableName(tableName);
            putItemRequest.addItemEntry("Key", new AttributeValue(imageKey));
            putItemRequest.addItemEntry("Bucket", new AttributeValue(bucketName));
            dynamoDbClient.putItem(putItemRequest);
            labController.logMessageToPage("Added imageKey: " + imageKey);
        } else {
            labController.logMessageToPage(
                    "Image doesn't exist on disk. Skipped: " + imageKey + "[" + filePath + "]");
        }
    } catch (Exception ex) {
        labController.logMessageToPage("addImage Error: " + ex.getMessage());
    }

}