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


Java DeleteObjectsRequest.setKeys方法代码示例

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


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

示例1: remove

import com.amazonaws.services.s3.model.DeleteObjectsRequest; //导入方法依赖的package包/类
@Override
public void remove(String accessKey) throws Exception {
	LogUtils.debug(LOG_TAG, "Deleting file with access key: " + accessKey);
	AmazonS3 s3Client = new AmazonS3Client(new DefaultAWSCredentialsProviderChain());
	DeleteObjectsRequest multiObjectDeleteRequest = new DeleteObjectsRequest(bucketName);
	
	List<KeyVersion> keys = new ArrayList<KeyVersion>();
	keys.add(new KeyVersion(accessKey));
	keys.add(new KeyVersion(accessKey + "_key"));
	        
	multiObjectDeleteRequest.setKeys(keys);

	s3Client.deleteObjects(multiObjectDeleteRequest);

	LogUtils.debug(LOG_TAG, "Deleted file with access key: " + accessKey);
}
 
开发者ID:darshanmaiya,项目名称:MCSFS,代码行数:17,代码来源:S3Store.java

示例2: deletePrefix

import com.amazonaws.services.s3.model.DeleteObjectsRequest; //导入方法依赖的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: deleteAllKeysOnPartialPath

import com.amazonaws.services.s3.model.DeleteObjectsRequest; //导入方法依赖的package包/类
public void deleteAllKeysOnPartialPath(String path) {
    ObjectListing objectListing = s3Client.listObjects(s3Bucket, getFullPath(path));

    if (objectListing.getObjectSummaries().isEmpty()) {
        return;
    }

    List<DeleteObjectsRequest.KeyVersion> keys = objectListing
            .getObjectSummaries()
            .stream()
            .map(objectSummary -> new DeleteObjectsRequest.KeyVersion(objectSummary.getKey()))
            .collect(Collectors.toList());

    DeleteObjectsRequest request = new DeleteObjectsRequest(s3Bucket);
    request.setKeys(keys);
    s3Client.deleteObjects(request);
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:18,代码来源:S3StoreService.java

示例4: shouldBatchDeleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsRequest; //导入方法依赖的package包/类
/**
 * Tests if an object can be deleted
 */
@Test
public void shouldBatchDeleteObjects() {
  final File uploadFile1 = new File(UPLOAD_FILE_NAME);
  final File uploadFile2 = new File(UPLOAD_FILE_NAME);
  final File uploadFile3 = new File(UPLOAD_FILE_NAME);
  final File uploadFile4 = new File(UPLOAD_FILE_NAME);

  s3Client.createBucket(BUCKET_NAME);

  s3Client
      .putObject(new PutObjectRequest(BUCKET_NAME, "1_" + UPLOAD_FILE_NAME, uploadFile1));
  s3Client
      .putObject(new PutObjectRequest(BUCKET_NAME, "2_" + UPLOAD_FILE_NAME, uploadFile2));
  s3Client
      .putObject(new PutObjectRequest(BUCKET_NAME, "3_" + UPLOAD_FILE_NAME, uploadFile3));

  final DeleteObjectsRequest multiObjectDeleteRequest = new DeleteObjectsRequest(BUCKET_NAME);

  final List<DeleteObjectsRequest.KeyVersion> keys = new ArrayList<>();
  keys.add(new DeleteObjectsRequest.KeyVersion("1_" + UPLOAD_FILE_NAME));
  keys.add(new DeleteObjectsRequest.KeyVersion("2_" + UPLOAD_FILE_NAME));
  keys.add(new DeleteObjectsRequest.KeyVersion("3_" + UPLOAD_FILE_NAME));
  keys.add(new DeleteObjectsRequest.KeyVersion("4_" + UPLOAD_FILE_NAME));

  multiObjectDeleteRequest.setKeys(keys);

  final DeleteObjectsResult delObjRes = s3Client.deleteObjects(multiObjectDeleteRequest);
  assertThat("Response should contain 4 entries", delObjRes.getDeletedObjects().size(), is(4));

  thrown.expect(AmazonS3Exception.class);
  thrown.expectMessage(containsString("Status Code: 406"));

  s3Client.getObject(BUCKET_NAME, UPLOAD_FILE_NAME);
}
 
开发者ID:adobe,项目名称:S3Mock,代码行数:38,代码来源:AmazonClientUploadIT.java

示例5: deleteKeyVersions

import com.amazonaws.services.s3.model.DeleteObjectsRequest; //导入方法依赖的package包/类
/**
 * Deletes a list of keys/key versions from the specified S3 bucket.
 *
 * @param s3Client the S3 client
 * @param s3BucketName the S3 bucket name
 * @param keyVersions the list of S3 keys/key versions
 */
private void deleteKeyVersions(AmazonS3Client s3Client, String s3BucketName, List<DeleteObjectsRequest.KeyVersion> keyVersions)
{
    // Create a request to delete multiple objects in the specified bucket.
    DeleteObjectsRequest multiObjectDeleteRequest = new DeleteObjectsRequest(s3BucketName);

    // The Multi-Object Delete request can contain a list of up to 1000 keys.
    for (int i = 0; i < keyVersions.size() / MAX_KEYS_PER_DELETE_REQUEST + 1; i++)
    {
        List<DeleteObjectsRequest.KeyVersion> keysSubList =
            keyVersions.subList(i * MAX_KEYS_PER_DELETE_REQUEST, Math.min(keyVersions.size(), (i + 1) * MAX_KEYS_PER_DELETE_REQUEST));
        multiObjectDeleteRequest.setKeys(keysSubList);
        try
        {
            s3Operations.deleteObjects(multiObjectDeleteRequest, s3Client);
        }
        catch (MultiObjectDeleteException multiObjectDeleteException)
        {
            logMultiObjectDeleteException(multiObjectDeleteException);
            throw multiObjectDeleteException;
        }

        LOGGER.info("Successfully requested the deletion of the listed below keys/key versions from the S3 bucket. s3KeyCount={} s3BucketName=\"{}\"",
            keysSubList.size(), s3BucketName);

        for (DeleteObjectsRequest.KeyVersion keyVersion : keysSubList)
        {
            LOGGER.info("s3Key=\"{}\" s3VersionId=\"{}\"", keyVersion.getKey(), keyVersion.getVersion());
        }
    }
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:38,代码来源:S3DaoImpl.java

示例6: deleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsRequest; //导入方法依赖的package包/类
@Override
public DeleteObjectsResult deleteObjects(final String bucketName, final List<KeyVersion> keys)
		throws AmazonClientException, AmazonServiceException {
	LOGGER.info("deleteObjects invoked, bucketName: {}, keys: {}", bucketName, keys);
	final DeleteObjectsRequest deleteObjReq = new DeleteObjectsRequest(bucketName);
	deleteObjReq.setKeys(keys);
	return s3client.deleteObjects(deleteObjReq);
}
 
开发者ID:abhinavmishra14,项目名称:aws-s3-utils,代码行数:9,代码来源:AwsS3IamServiceImpl.java

示例7: deleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsRequest; //导入方法依赖的package包/类
private static void deleteObjects(AmazonS3 s3, String s3BucketName, List<S3ObjectSummary> objSummaries, List<DeleteObjectsRequest.KeyVersion> keys, int accum){

		Logger.log(new Throwable(), "deleting " + (objSummaries.size() - accum) + " objects...");
		DeleteObjectsRequest deleteResquests = new DeleteObjectsRequest(s3BucketName);
		deleteResquests.setKeys(keys);
		s3.deleteObjects(deleteResquests);

	}
 
开发者ID:matsufan,项目名称:tales-core,代码行数:9,代码来源:S3DeleteBucket.java


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