Solution 1:

Here is an example from AWS S3 Event notification using Lambda function in Java:

public Object handleRequest(S3Event input, Context context) {
AmazonS3Client s3Client = new AmazonS3Client(new DefaultAWSCredentialsProviderChain());        

for (S3EventNotificationRecord record : input.getRecords()) {
    String s3Key = record.getS3().getObject().getKey();
    String s3Bucket = record.getS3().getBucket().getName();

    // retrieve s3 object
    S3Object object = s3Client.getObject(new GetObjectRequest(s3Bucket, s3Key));
    InputStream objectData = object.getObjectContent();

    ...
}        
return "success";}