当前位置: 首页>>代码示例>>Java>>正文


Java S3Objects.withPrefix方法代码示例

本文整理汇总了Java中com.amazonaws.services.s3.iterable.S3Objects.withPrefix方法的典型用法代码示例。如果您正苦于以下问题:Java S3Objects.withPrefix方法的具体用法?Java S3Objects.withPrefix怎么用?Java S3Objects.withPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.s3.iterable.S3Objects的用法示例。


在下文中一共展示了S3Objects.withPrefix方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCachedConfigurations

import com.amazonaws.services.s3.iterable.S3Objects; //导入方法依赖的package包/类
@Override
public Stream<WriteableConfiguration> getCachedConfigurations() throws IOException {

  Iterable<S3ObjectSummary> objectSummaries = S3Objects.withPrefix(s3, bucket, prefix);
  Stream<S3ObjectSummary> objectStream = StreamSupport.stream(objectSummaries.spliterator(), false);

  return objectStream.map(p -> {
    Integer version = getVersionIfMatch(p.getKey());
    if (version == null) {
      return null;
    }
    return new Pair<>(version, p);
  }).filter(Objects::nonNull)
      .sorted(Comparator.comparing(pair -> ((Pair<Integer, S3ObjectSummary>) pair).getFirst())
            .reversed()).map(pair -> new S3WritableConfiguration(s3, pair.getSecond(), Integer.toString(pair.getFirst())));

}
 
开发者ID:apache,项目名称:nifi-minifi,代码行数:18,代码来源:S3CacheFileInfoImpl.java

示例2: deletePrefix

import com.amazonaws.services.s3.iterable.S3Objects; //导入方法依赖的package包/类
static void deletePrefix(AmazonS3 s3Client, String bucketName, String prefix) {
    List<DeleteObjectsRequest.KeyVersion> trashKeys = new ArrayList<>();
    DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(bucketName);
    for (S3ObjectSummary summary: S3Objects.withPrefix(s3Client, bucketName, prefix)) {
        trashKeys.add(new DeleteObjectsRequest.KeyVersion(summary.getKey()));
        if (trashKeys.size() == BULK_DELETE_SIZE) {
            deleteObjectsRequest.setKeys(trashKeys);
            s3Client.deleteObjects(deleteObjectsRequest);
            trashKeys.clear();
        }
    }
    if (!trashKeys.isEmpty()) {
        deleteObjectsRequest.setKeys(trashKeys);
        s3Client.deleteObjects(deleteObjectsRequest);
    }
}
 
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:17,代码来源:S3Utilities.java

示例3: copy

import com.amazonaws.services.s3.iterable.S3Objects; //导入方法依赖的package包/类
@Override
protected void copy(RuntimeExecutionTrace source, RuntimeExecutionTrace target,
        RuntimeAnnotatedExecutionTrace absoluteSource, RuntimeAnnotatedExecutionTrace absoluteTarget)
        throws IOException {
    String sourcePrefix = toS3Path(source).getPrefixForChildren();
    String targetPrefix = toS3Path(target).getPrefixForChildren();
    for (S3ObjectSummary summary: S3Objects.withPrefix(s3Client, bucketName, sourcePrefix)) {
        if (summary.getKey().startsWith(sourcePrefix)) {
            String relativeKey = summary.getKey().substring(sourcePrefix.length());
            s3Client.copyObject(bucketName, summary.getKey(), bucketName, targetPrefix + relativeKey);
        } else {
            log.error(String.format(
                "S3Objects.withPrefix() returned unexpected key '%s' when asked for prefix '%s'.",
                summary.getKey(), sourcePrefix
            ));
        }
    }
}
 
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:19,代码来源:S3StagingArea.java

示例4: main

import com.amazonaws.services.s3.iterable.S3Objects; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	DeleteBucketRequest deleteBucketRequest=new DeleteBucketRequest(AWSResources.S3_BUCKET_NAME);
	if(AWSResources.S3.doesBucketExist(AWSResources.S3_BUCKET_NAME))
		try {
				AWSResources.S3.deleteBucket(deleteBucketRequest);
				System.out.println("Bucket Deleted...");
		}
	catch (AmazonS3Exception ex) {
		if(!ex.getErrorCode().equals("BucketNotEmpty"))
			throw ex;
	}
	//List<KeyVersion> keys = new ArrayList<KeyVersion>();
	for(S3ObjectSummary obj : S3Objects.withPrefix(AWSResources.S3, AWSResources.S3_BUCKET_NAME, "")) {
    // Add the keys to our list of object.
    AWSResources.S3.deleteObject(AWSResources.S3_BUCKET_NAME, obj.getKey());
	}
	//DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(AWSResources.S3_BUCKET_NAME);
	//AWSResources.S3.deleteObjects(deleteObjectsRequest);
	AWSResources.S3.deleteBucket(deleteBucketRequest);
	if(!AWSResources.S3.doesBucketExist(AWSResources.S3_BUCKET_NAME))
		System.out.println("Deleted");
}
 
开发者ID:snehangshuk,项目名称:aws,代码行数:23,代码来源:DeleteObject.java

示例5: getBlobIdStream

import com.amazonaws.services.s3.iterable.S3Objects; //导入方法依赖的package包/类
@Override
public Stream<BlobId> getBlobIdStream() {
  Iterable<S3ObjectSummary> summaries = S3Objects.withPrefix(s3, getConfiguredBucket(), CONTENT_PREFIX);
  return StreamSupport.stream(summaries.spliterator(), false)
    .map(S3ObjectSummary::getKey)
    .map(key -> key.substring(key.lastIndexOf('/') + 1, key.length()))
    .filter(filename -> filename.endsWith(BLOB_ATTRIBUTE_SUFFIX) && !filename.startsWith(TEMPORARY_BLOB_ID_PREFIX))
    .map(filename -> filename.substring(0, filename.length() - BLOB_ATTRIBUTE_SUFFIX.length()))
    .map(BlobId::new);
}
 
开发者ID:sonatype,项目名称:nexus-blobstore-s3,代码行数:11,代码来源:S3BlobStore.java

示例6: getObjectSummary

import com.amazonaws.services.s3.iterable.S3Objects; //导入方法依赖的package包/类
static S3ObjectSummary getObjectSummary(AmazonS3 s3Client, String bucket, String objectKey) {
  S3ObjectSummary s3ObjectSummary = null;
  S3Objects s3ObjectSummaries = S3Objects.withPrefix(s3Client, bucket, objectKey);
  for (S3ObjectSummary s : s3ObjectSummaries) {
    if (s.getKey().equals(objectKey)) {
      s3ObjectSummary = s;
      break;
    }
  }
  return s3ObjectSummary;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:12,代码来源:AmazonS3Util.java

示例7: getObjectSummaries

import com.amazonaws.services.s3.iterable.S3Objects; //导入方法依赖的package包/类
private Map<Pair<String, String>, S3ObjectSummary> getObjectSummaries(AmazonS3 s3Client, String bucket, String prefix) {
  Map<Pair<String, String>, S3ObjectSummary> s3ObjectSummaries = new HashMap<>();
  for(S3ObjectSummary s : S3Objects.withPrefix(s3Client, bucket, prefix)) {
    s3ObjectSummaries.put(Pair.of(bucket, s.getKey()), s);
  }
  return s3ObjectSummaries;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:8,代码来源:TestAmazonS3Source.java

示例8: getObjectCount

import com.amazonaws.services.s3.iterable.S3Objects; //导入方法依赖的package包/类
private int getObjectCount(AmazonS3 s3Client, String bucket, String prefix) {
  int count = 0;
  for(S3ObjectSummary ignored : S3Objects.withPrefix(s3Client, bucket, prefix)) {
    count++;
  }
  return count;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:8,代码来源:TestAmazonS3Source.java

示例9: start

import com.amazonaws.services.s3.iterable.S3Objects; //导入方法依赖的package包/类
private void start() throws IOException, InterruptedException {
    AmazonS3Client s3Client = new AmazonS3Client();

    S3Objects s3Objects = S3Objects.withPrefix(s3Client, config.getS3Bucket(), config.getS3Key());

    final ElasticWriter elasticWriter = new ElasticWriter(config.getElasticIndexName(), config.getElasticHost(), config.getElasticPort());

    int count = 0;
    for (S3ObjectSummary s3ObjectSummary : s3Objects) {
        s3ObjectSummary.getKey();

        S3Object object = s3Client.getObject(s3ObjectSummary.getBucketName(), s3ObjectSummary.getKey());
        log.info("Downloading content of: {}", object.getKey());

        S3ObjectInputStream objectContentStream = object.getObjectContent();

        BufferedReader reader = new BufferedReader(new InputStreamReader(objectContentStream));

        String line = null;
        while ((line = reader.readLine()) != null) {
            Scanner scanner = new Scanner(line).useDelimiter("\t");

            String t1 = scanner.next();
            String t2 = scanner.next();
            Integer value = scanner.nextInt();

            elasticWriter.write(t1, t2, value);
            count++;
        }

        log.info("Wrote {} pairs", count);
    }
}
 
开发者ID:FutureProcessing,项目名称:what-should-i-learn-next,代码行数:34,代码来源:PopulateElastic.java

示例10: getBlobIdStream

import com.amazonaws.services.s3.iterable.S3Objects; //导入方法依赖的package包/类
@Override
public Stream<BlobId> getBlobIdStream() {
  Iterable<S3ObjectSummary> summaries = S3Objects.withPrefix(s3, getConfiguredBucket(), CONTENT_PREFIX);
  return blobIdStream(summaries);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:6,代码来源:S3BlobStore.java

示例11: getDirectPathBlobIdStream

import com.amazonaws.services.s3.iterable.S3Objects; //导入方法依赖的package包/类
@Override
public Stream<BlobId> getDirectPathBlobIdStream(final String prefix) {
  String subpath = format("%s/%s/%s", CONTENT_PREFIX, DIRECT_PATH_ROOT, prefix);
  Iterable<S3ObjectSummary> summaries = S3Objects.withPrefix(s3, getConfiguredBucket(), subpath);
  return blobIdStream(summaries);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:7,代码来源:S3BlobStore.java

示例12: main

import com.amazonaws.services.s3.iterable.S3Objects; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	for (S3ObjectSummary summary : S3Objects.withPrefix(AWSResources.S3, AWSResources.S3_BUCKET_NAME, "photos/")) {
		System.out.printf("Object with key '%s'\n", summary.getKey());
	}
}
 
开发者ID:snehangshuk,项目名称:aws,代码行数:6,代码来源:ListFilesInBucket.java


注:本文中的com.amazonaws.services.s3.iterable.S3Objects.withPrefix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。