コード例 #1
0
  public List<URI> listObjects(URI storageArea) {
    S3StorageHelper.checkValidS3Uri(storageArea);

    String s3Path = getS3ObjectKey(storageArea);
    Iterable<S3ObjectSummary> objectListing =
        new S3ObjectListing(
            s3Service, new ListObjectsRequest(getS3Bucket(storageArea), s3Path, null, "/", null));

    ImmutableList.Builder<URI> builder = ImmutableList.builder();
    for (S3ObjectSummary summary : objectListing) {
      builder.add(buildS3Location(storageArea, summary.getKey().substring(s3Path.length())));
    }
    return builder.build();
  }
コード例 #2
0
  public List<URI> listDirectoriesNewestFirst(URI storageArea) {
    S3StorageHelper.checkValidS3Uri(storageArea);

    String bucket = getS3Bucket(storageArea);
    String key = getS3ObjectKey(storageArea);
    Iterator<String> iter =
        new S3PrefixListing(s3Service, new ListObjectsRequest(bucket, key, null, "/", null))
            .iterator();

    ImmutableList.Builder<URI> builder = ImmutableList.builder();
    while (iter.hasNext()) {
      builder.add(buildS3Location("s3://", bucket, iter.next()));
    }
    return builder.build().reverse();
  }