code: protected String doesContentExistWithExpectedChecksum(String bucketName,
                                                            String contentId,
                                                            String expectedChecksum) {
          int maxAttempts = 20;
          int waitInSeconds = 2;
          int attempts = 0;
          int totalSecondsWaited = 0;
          String etag = null;
          for (int i = 0; i < maxAttempts; i++) {
              try {
                  ObjectMetadata metadata =
                      s3Client.getObjectMetadata(bucketName, contentId);
                  if (null != metadata) {
                      if (attempts > 5) {
                          log.info("contentId={} found in bucket={} after waiting for {} seconds...",
                                   contentId,
                                   bucketName,
                                   totalSecondsWaited);
                      }
  
                      etag = metadata.getETag();
  
                      if (expectedChecksum.equals(getETagValue(etag))) {
                          return etag;
                      }
  
                  }
              } catch (AmazonClientException e) {
                  // Content item is not yet available
              }
  
              attempts++;
              int waitNow = waitInSeconds * i;
              wait(waitNow);
              totalSecondsWaited += waitNow;
          }
  
          if (etag == null) {
              log.warn("contentId={} NOT found in bucket={} after waiting for {} seconds...",
                       contentId,
                       bucketName,
                       attempts * waitInSeconds);
          } else {
              log.warn("contentId={} in bucket={} does not have the expected checksum after waiting " +
                       "for {} seconds. S3 Checksum={} Expected Checksum={}",
                       contentId,
                       bucketName,
                       attempts * waitInSeconds,
                       getETagValue(etag),
                       expectedChecksum);
  
          }
  
          return etag;
      }
docs: /*
  Determines if a content item exists and if so if the MD5 matches what was
  expected. If so, returns its MD5. If not, returns null. This method is
  necessary because S3 GETs are non-atomic. Therefore it is possible for
  the put to succeed while a subsequent GET may return results inconsistent
  with the most recent state of S3.