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


Java ObjectListing.getObjectSummaries方法代码示例

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


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

示例1: deleteAll

import com.amazonaws.services.s3.model.ObjectListing; //导入方法依赖的package包/类
public void deleteAll(String bucket) {
    logger.info("delete all from bucket, bucket={}", bucket);

    ObjectListing listing = s3.listObjects(new ListObjectsRequest().withBucketName(bucket));

    while (listing != null) {
        List<DeleteObjectsRequest.KeyVersion> keys = new ArrayList<>(listing.getObjectSummaries().size());
        for (S3ObjectSummary summary : listing.getObjectSummaries()) {
            String key = summary.getKey();
            logger.info("add key to deletion batch, key={}", key);
            keys.add(new DeleteObjectsRequest.KeyVersion(key));
        }
        if (!keys.isEmpty()) {
            logger.info("delete key batch");
            s3.deleteObjects(new DeleteObjectsRequest(bucket).withKeys(keys));
        }
        if (!listing.isTruncated()) return;

        listing = s3.listNextBatchOfObjects(listing);
    }
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:22,代码来源:S3.java

示例2: getFileList

import com.amazonaws.services.s3.model.ObjectListing; //导入方法依赖的package包/类
@Override
public void getFileList(String path, OutputStream out) throws Exception {
  String marker = null;
  do {
    ListObjectsRequest request = new ListObjectsRequest(bucketName, path, null, "/", 1000);
    ObjectListing listing = client.listObjects(request);
    for (S3ObjectSummary object : listing.getObjectSummaries()) {
      String line = object.getKey() + "\n";
      out.write(line.getBytes());
    }
    for (String commonPrefix : listing.getCommonPrefixes()) {
      getFileList(commonPrefix, out);
    }
    marker = listing.getNextMarker();
  } while (marker != null);
}
 
开发者ID:XiaoMi,项目名称:galaxy-fds-migration-tool,代码行数:17,代码来源:S3Source.java

示例3: list

import com.amazonaws.services.s3.model.ObjectListing; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unused")
public List<AwsFileMiniModel> list(String prefix) {

	AmazonS3 s3client = new AmazonS3Client(new ProfileCredentialsProvider());
	List<AwsFileMiniModel> files = new ArrayList();

	ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucketName).withPrefix(prefix);
	ObjectListing objectListing;

	do {
		objectListing = s3client.listObjects(listObjectsRequest);

		for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) {
			System.out.println(" - " + objectSummary.getKey() + "  " + "(size = " + objectSummary.getSize() + ")"
					+ " (date = " + objectSummary.getLastModified() + ")");
			files.add(new AwsFileMiniModel(objectSummary.getKey(), objectSummary.getLastModified()));
		}
		listObjectsRequest.setMarker(objectListing.getNextMarker());
	} while (objectListing.isTruncated());

	return files;

}
 
开发者ID:ismartonline,项目名称:ismartonline,代码行数:25,代码来源:AwsFileManager.java

示例4: deleteByTenant

import com.amazonaws.services.s3.model.ObjectListing; //导入方法依赖的package包/类
@Override
public void deleteByTenant(final String tenant) {
    final String folder = sanitizeTenant(tenant);

    LOG.info("Deleting S3 object folder (tenant) from bucket {} and key {}", s3Properties.getBucketName(), folder);

    // Delete artifacts
    ObjectListing objects = amazonS3.listObjects(s3Properties.getBucketName(), folder + "/");
    do {
        for (final S3ObjectSummary objectSummary : objects.getObjectSummaries()) {
            amazonS3.deleteObject(s3Properties.getBucketName(), objectSummary.getKey());
        }
        objects = amazonS3.listNextBatchOfObjects(objects);
    } while (objects.isTruncated());

}
 
开发者ID:eclipse,项目名称:hawkbit-extensions,代码行数:17,代码来源:S3Repository.java

示例5: main

import com.amazonaws.services.s3.model.ObjectListing; //导入方法依赖的package包/类
public static void main(String[] args)
{
    final String USAGE = "\n" +
        "To run this example, supply the name of a bucket to list!\n" +
        "\n" +
        "Ex: ListObjects <bucket-name>\n";

    if (args.length < 1) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String bucket_name = args[0];

    System.out.format("Objects in S3 bucket %s:\n", bucket_name);
    final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient();
    ObjectListing ol = s3.listObjects(bucket_name);
    List<S3ObjectSummary> objects = ol.getObjectSummaries();
    for (S3ObjectSummary os: objects) {
        System.out.println("* " + os.getKey());
    }
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:23,代码来源:ListObjects.java

示例6: list

import com.amazonaws.services.s3.model.ObjectListing; //导入方法依赖的package包/类
@Override
public List<NoteInfo> list(AuthenticationInfo subject) throws IOException {
  List<NoteInfo> infos = new LinkedList<>();
  NoteInfo info;
  try {
    ListObjectsRequest listObjectsRequest = new ListObjectsRequest()
            .withBucketName(bucketName)
            .withPrefix(user + "/" + "notebook");
    ObjectListing objectListing;
    do {
      objectListing = s3client.listObjects(listObjectsRequest);
      for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) {
        if (objectSummary.getKey().endsWith("note.json")) {
          info = getNoteInfo(objectSummary.getKey());
          if (info != null) {
            infos.add(info);
          }
        }
      }
      listObjectsRequest.setMarker(objectListing.getNextMarker());
    } while (objectListing.isTruncated());
  } catch (AmazonClientException ace) {
    throw new IOException("Unable to list objects in S3: " + ace, ace);
  }
  return infos;
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:27,代码来源:S3NotebookRepo.java

示例7: remove

import com.amazonaws.services.s3.model.ObjectListing; //导入方法依赖的package包/类
@Override
public void remove(String noteId, AuthenticationInfo subject) throws IOException {
  String key = user + "/" + "notebook" + "/" + noteId;
  final ListObjectsRequest listObjectsRequest = new ListObjectsRequest()
      .withBucketName(bucketName).withPrefix(key);

  try {
    ObjectListing objects = s3client.listObjects(listObjectsRequest);
    do {
      for (S3ObjectSummary objectSummary : objects.getObjectSummaries()) {
        s3client.deleteObject(bucketName, objectSummary.getKey());
      }
      objects = s3client.listNextBatchOfObjects(objects);
    } while (objects.isTruncated());
  }
  catch (AmazonClientException ace) {
    throw new IOException("Unable to remove note in S3: " + ace, ace);
  }
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:20,代码来源:S3NotebookRepo.java

示例8: getAllChildren

import com.amazonaws.services.s3.model.ObjectListing; //导入方法依赖的package包/类
public ArrayList<String> getAllChildren(String folderName) throws IOException {
    ListObjectsRequest listRequest = new ListObjectsRequest();
    listRequest.setBucketName(getBucketName());
    listRequest.setPrefix(folderName);

    ObjectListing listing = s3.listObjects(listRequest);

    ArrayList<String> list = new ArrayList<String>();

    System.out.println(listing.getObjectSummaries().size());

    for (S3ObjectSummary summ : listing.getObjectSummaries()) {
        list.add(summ.getKey());
    }

    return list;
}
 
开发者ID:modcs,项目名称:caboclo,代码行数:18,代码来源:AmazonClient.java

示例9: listBucket

import com.amazonaws.services.s3.model.ObjectListing; //导入方法依赖的package包/类
public List<String> listBucket(String bkt, String prefix, String delimiter) throws IOException {

        ListObjectsRequest listRequest = new ListObjectsRequest();
        listRequest.setBucketName(bkt);
        listRequest.setDelimiter(delimiter);
        listRequest.setPrefix(prefix);

        ObjectListing listing = s3.listObjects(listRequest);

        ArrayList<String> list = new ArrayList<String>();

        for (S3ObjectSummary summ : listing.getObjectSummaries()) {
            list.add(summ.getKey());
        }

        return list;
    }
 
开发者ID:modcs,项目名称:caboclo,代码行数:18,代码来源:AmazonClient.java

示例10: afterSpiStopped

import com.amazonaws.services.s3.model.ObjectListing; //导入方法依赖的package包/类
/**
 * @throws Exception If error.
 */
@Override protected void afterSpiStopped() throws Exception {
    AWSCredentials cred = new BasicAWSCredentials(IgniteS3TestSuite.getAccessKey(),
        IgniteS3TestSuite.getSecretKey());

    AmazonS3 s3 = new AmazonS3Client(cred);

    String bucketName = S3CheckpointSpi.BUCKET_NAME_PREFIX + "unit-test-bucket";

    try {
        ObjectListing list = s3.listObjects(bucketName);

        while (true) {
            for (S3ObjectSummary sum : list.getObjectSummaries())
                s3.deleteObject(bucketName, sum.getKey());

            if (list.isTruncated())
                list = s3.listNextBatchOfObjects(list);
            else
                break;
        }
    }
    catch (AmazonClientException e) {
        throw new IgniteSpiException("Failed to read checkpoint bucket: " + bucketName, e);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:29,代码来源:S3CheckpointSpiSelfTest.java

示例11: testListObjectsWithNoPathWithPrefix

import com.amazonaws.services.s3.model.ObjectListing; //导入方法依赖的package包/类
@Test
public void testListObjectsWithNoPathWithPrefix() throws Exception {
    client.createBucket("test-bucket");
    putObject("test-bucket", "no-path-1", "foobar");
    putObject("test-bucket", "no-path-2", "");
    putObject("test-bucket", "/one/prefix-1.xml", "foobar");
    putObject("test-bucket", "/no-path/two/prefix-1.xml", "foobar");
    putObject("test-bucket", "/two/prefix-1.xml", "foobar");
    putObject("test-bucket", "/file/with/loads/of/slashes-3.png", "dfsrgt3");

    ObjectListing objectListing = client.listObjects("test-bucket", "no-path");

    List<String> objectKeys = new ArrayList<>();

    for(S3ObjectSummary s3ObjectSummary : objectListing.getObjectSummaries()) {
        assertEquals("test-bucket", s3ObjectSummary.getBucketName());
        objectKeys.add(s3ObjectSummary.getKey());
    }

    assertEquals(3, objectKeys.size());
    assertTrue(objectKeys.contains("no-path-1"));
    assertTrue(objectKeys.contains("no-path-2"));
    assertTrue(objectKeys.contains("/no-path/two/prefix-1.xml"));
}
 
开发者ID:michaeltandy,项目名称:s3test,代码行数:25,代码来源:ListObjectsTest.java

示例12: deleteCollection

import com.amazonaws.services.s3.model.ObjectListing; //导入方法依赖的package包/类
@Override
public void deleteCollection(Map<String, Object> attributes, String collectionName) 
   throws IOException 
{
   if (s3Client==null) {
      throw new IOException("S3 Client is not available due to configuration error.");
   }
   String bucketName = getBucketName(attributes);
   if (bucketName==null) {
      throw new IOException("S3 Bucket not configured for "+attributes.get("app.database"));
   }
   try {
      ObjectListing listing = null;
      do {
         listing = listing==null ? s3Client.listObjects(bucketName, collectionName+"/") : s3Client.listNextBatchOfObjects(listing);
         for (S3ObjectSummary summary : listing.getObjectSummaries()) {
            s3Client.deleteObject(bucketName, summary.getKey());
         }
      } while (listing.isTruncated());
   } catch (AmazonClientException ex) {
      throw new IOException("Cannot delete collection objects due to S3 error.",ex);
   }
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:24,代码来源:S3MediaStorage.java

示例13: getFilenamesFromListing

import com.amazonaws.services.s3.model.ObjectListing; //导入方法依赖的package包/类
private List<String> getFilenamesFromListing(ObjectListing listing, String prefix) {
    List<String> results = new ArrayList<String>(100);

    for (S3ObjectSummary summary : listing.getObjectSummaries()) {
        final String key = summary.getKey();
        final String filename;
        
        filename = key.substring(prefix.length());
        if (filename.length() == 0 || filename.contains(DELIMITER)) {
            log.error("Error parsing S3 object Key.  Key: " + key);
            continue;
        }
        results.add(filename);
    }
    
    return results;
}
 
开发者ID:indeedeng,项目名称:imhotep,代码行数:18,代码来源:S3RemoteFileSystem.java

示例14: list

import com.amazonaws.services.s3.model.ObjectListing; //导入方法依赖的package包/类
@Override
public List<String> list() {
	List<String> files = new ArrayList<String>();
	if(s3URI == null) return files;
	String[] buckAndKey = this.getBucketAndKey();
	String bucket = buckAndKey[0];
	String key = buckAndKey[1];
	ObjectListing objectListing = s3. listObjects(new ListObjectsRequest().withBucketName(bucket).withPrefix(key));
	s3list: for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) {
		// check for valid extensions
		if(extensions == null){
			files.add("s3://"+bucket+"/"+objectSummary.getKey());
		} else for(String ext : extensions) if(objectSummary.getKey().endsWith(ext)){
			files.add("s3://"+bucket+"/"+objectSummary.getKey());
			continue s3list;
		}
	 }
	return files;
}
 
开发者ID:sensorstorm,项目名称:StormCV,代码行数:20,代码来源:S3Connector.java

示例15: testEmptyBucketReturnsExpectedObjects

import com.amazonaws.services.s3.model.ObjectListing; //导入方法依赖的package包/类
@Test
public void testEmptyBucketReturnsExpectedObjects() throws Exception {
    client.createBucket("test-bucket");
    putObject("test-bucket", "file-1", "foobar");
    putObject("test-bucket", "file-2", "");
    putObject("test-bucket", "/file/with/slashes-1.xml", "foobar");
    putObject("test-bucket", "/file/with/loads/of/slashes-3.png", "dfsrgt3");

    ObjectListing objectListing = client.listObjects("test-bucket");

    List<String> objectKeys = new ArrayList<>();

    for(S3ObjectSummary s3ObjectSummary : objectListing.getObjectSummaries()) {
        assertEquals("test-bucket", s3ObjectSummary.getBucketName());
        objectKeys.add(s3ObjectSummary.getKey());
    }

    assertEquals(4, objectKeys.size());
    assertTrue(objectKeys.contains("file-1"));
    assertTrue(objectKeys.contains("file-2"));
    assertTrue(objectKeys.contains("/file/with/slashes-1.xml"));
    assertTrue(objectKeys.contains("/file/with/loads/of/slashes-3.png"));
}
 
开发者ID:michaeltandy,项目名称:s3test,代码行数:24,代码来源:ListObjectsTest.java


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