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


Java DeleteObjectsResult类代码示例

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


DeleteObjectsResult类属于com.amazonaws.services.s3.model包,在下文中一共展示了DeleteObjectsResult类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDeleteMultipleObjects

import com.amazonaws.services.s3.model.DeleteObjectsResult; //导入依赖的package包/类
@Test
public void testDeleteMultipleObjects() throws Exception {
    String blobName = "foo";
    ObjectMetadata metadata = new ObjectMetadata();
    metadata.setContentLength(BYTE_SOURCE.size());

    DeleteObjectsRequest request = new DeleteObjectsRequest(containerName)
            .withKeys(blobName);

    // without quiet
    client.putObject(containerName, blobName, BYTE_SOURCE.openStream(),
            metadata);

    DeleteObjectsResult result = client.deleteObjects(request);
    assertThat(result.getDeletedObjects()).hasSize(1);
    assertThat(result.getDeletedObjects().iterator().next().getKey())
            .isEqualTo(blobName);

    // with quiet
    client.putObject(containerName, blobName, BYTE_SOURCE.openStream(),
            metadata);

    result = client.deleteObjects(request.withQuiet(true));
    assertThat(result.getDeletedObjects()).isEmpty();
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:26,代码来源:AwsSdkTest.java

示例2: shouldBatchDeleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsResult; //导入依赖的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

示例3: deleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsResult; //导入依赖的package包/类
@Override
public DeleteObjectsResult deleteObjects(DeleteObjectsRequest deleteObjectsRequest, AmazonS3 s3Client)
{
    LOGGER.debug("deleteObjects(): deleteObjectRequest.getBucketName() = " + deleteObjectsRequest.getBucketName() + ", deleteObjectRequest.getKeys() = " +
        deleteObjectsRequest.getKeys());

    List<DeletedObject> deletedObjects = new ArrayList<>();

    MockS3Bucket mockS3Bucket = mockS3Buckets.get(deleteObjectsRequest.getBucketName());

    for (KeyVersion keyVersion : deleteObjectsRequest.getKeys())
    {
        String s3ObjectKey = keyVersion.getKey();
        String s3ObjectVersion = keyVersion.getVersion();
        String s3ObjectKeyVersion = s3ObjectKey + (s3ObjectVersion != null ? s3ObjectVersion : "");

        mockS3Bucket.getObjects().remove(s3ObjectKey);

        if (mockS3Bucket.getVersions().remove(s3ObjectKeyVersion) != null)
        {
            DeletedObject deletedObject = new DeletedObject();
            deletedObject.setKey(s3ObjectKey);
            deletedObject.setVersionId(s3ObjectVersion);
            deletedObjects.add(deletedObject);
        }
    }

    return new DeleteObjectsResult(deletedObjects);
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:30,代码来源:MockS3OperationsImpl.java

示例4: deleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsResult; //导入依赖的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

示例5: testDeleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsResult; //导入依赖的package包/类
/**
 * Test method for {@link com.github.abhinavmishra14.aws.s3.service.AwsS3IamService#deleteObjects(java.lang.String,java.util.List)}.
 *
 * @throws Exception the exception
 */
@Test
public void testDeleteObjects() throws Exception {
	List<KeyVersion> keys = new ArrayList<KeyVersion>();
	KeyVersion key1= new KeyVersion(AWSUtilConstants.SAMPLE_FILE_NAME);
	KeyVersion key2= new KeyVersion("TestPutObject2.txt");
	keys.add(key1);
	keys.add(key2);
	awsS3IamService.createBucket(AWS_S3_BUCKET);//create bucket for test
	DeleteObjectsResult delResp = awsS3IamService.deleteObjects(AWS_S3_BUCKET,keys);
	assertNotNull(delResp);
}
 
开发者ID:abhinavmishra14,项目名称:aws-s3-utils,代码行数:17,代码来源:AwsS3IamServiceTest.java

示例6: deleteEntities

import com.amazonaws.services.s3.model.DeleteObjectsResult; //导入依赖的package包/类
@Override
public boolean deleteEntities(String bucketName) {
	LOG.info("Deletes multiple objects in a bucket " + bucketName + " from Amazon S3");
	List<S3ObjectSummary> s3ObjectSummaries = findEntityByBucket(bucketName);
	if (s3ObjectSummaries == null || s3ObjectSummaries.isEmpty()) {
	    return false;
	}
	
	// Provide a list of object keys and versions.
	List<KeyVersion> keyVersions = new ArrayList<KeyVersion>();
	for (S3ObjectSummary s3ObjectSummary : s3ObjectSummaries) {
		keyVersions.add( new KeyVersion(s3ObjectSummary.getKey()));
	}

	try {
	    DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(bucketName)
	        .withKeys(keyVersions);
	    DeleteObjectsResult deleteObjectsResult = amazonS3Client.deleteObjects(deleteObjectsRequest);
	    if (deleteObjectsResult != null) {
	    	LOG.info("Successfully deleted all the "
                    + deleteObjectsResult.getDeletedObjects().size() + " items.\n");
	    	return true;
	    }
	} catch (AmazonServiceException ase) {
           LOG.warn(ase.getMessage(), ase);
       } catch (AmazonClientException ace) {
           LOG.warn(ace.getMessage(), ace);
	}
	return false;
}
 
开发者ID:dgks0n,项目名称:milton-aws,代码行数:31,代码来源:AmazonS3ManagerImpl.java

示例7: deleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsResult; //导入依赖的package包/类
@Override
public DeleteObjectsResult deleteObjects(DeleteObjectsRequest deleteObjectsRequest) throws AmazonClientException, AmazonServiceException {
    return delegate.deleteObjects(deleteObjectsRequest);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AmazonS3Wrapper.java

示例8: deleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsResult; //导入依赖的package包/类
@Override
public DeleteObjectsResult deleteObjects(DeleteObjectsRequest deleteObjectsRequest) {
    deleteObjectsRequest = beforeClientExecution(deleteObjectsRequest);
    Request<DeleteObjectsRequest> request = createRequest(deleteObjectsRequest.getBucketName(), null, deleteObjectsRequest, HttpMethodName.POST);
    request.addParameter("delete", null);

    if ( deleteObjectsRequest.getMfa() != null ) {
        populateRequestWithMfaDetails(request, deleteObjectsRequest.getMfa());
    }

    populateRequesterPaysHeader(request, deleteObjectsRequest.isRequesterPays());

    byte[] content = new MultiObjectDeleteXmlFactory().convertToXmlByteArray(deleteObjectsRequest);
    request.addHeader("Content-Length", String.valueOf(content.length));
    request.addHeader("Content-Type", "application/xml");
    request.setContent(new ByteArrayInputStream(content));
    try {
        byte[] md5 = Md5Utils.computeMD5Hash(content);
        String md5Base64 = BinaryUtils.toBase64(md5);
        request.addHeader("Content-MD5", md5Base64);
    } catch ( Exception e ) {
        throw new SdkClientException("Couldn't compute md5 sum", e);
    }

    @SuppressWarnings("unchecked")
    ResponseHeaderHandlerChain<DeleteObjectsResponse> responseHandler = new ResponseHeaderHandlerChain<DeleteObjectsResponse>(
            new Unmarshallers.DeleteObjectsResultUnmarshaller(),
            new S3RequesterChargedHeaderHandler<DeleteObjectsResponse>());

    DeleteObjectsResponse response = invoke(request, responseHandler, deleteObjectsRequest.getBucketName(), null);

    /*
     * If the result was only partially successful, throw an exception
     */
    if ( !response.getErrors().isEmpty() ) {
        Map<String, String> headers = responseHandler.getResponseHeaders();

        MultiObjectDeleteException ex = new MultiObjectDeleteException(
                response.getErrors(),
                response.getDeletedObjects());

        ex.setStatusCode(200);
        ex.setRequestId(headers.get(Headers.REQUEST_ID));
        ex.setExtendedRequestId(headers.get(Headers.EXTENDED_REQUEST_ID));
        ex.setCloudFrontId(headers.get(Headers.CLOUD_FRONT_ID));

        throw ex;
    }
    DeleteObjectsResult result = new DeleteObjectsResult(response.getDeletedObjects(), response.isRequesterCharged());

    return result;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:53,代码来源:AmazonS3Client.java

示例9: deleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsResult; //导入依赖的package包/类
@Override
public DeleteObjectsResult deleteObjects(DeleteObjectsRequest deleteObjectsRequest) throws SdkClientException, AmazonServiceException {
  return call(() -> getDelegate().deleteObjects(deleteObjectsRequest));
}
 
开发者ID:HubSpot,项目名称:S3Decorators,代码行数:5,代码来源:S3Decorator.java

示例10: deleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsResult; //导入依赖的package包/类
@Override
public DeleteObjectsResult deleteObjects(DeleteObjectsRequest deleteObjectsRequest, AmazonS3 s3Client)
{
    return s3Client.deleteObjects(deleteObjectsRequest);
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:6,代码来源:S3OperationsImpl.java

示例11: deleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsResult; //导入依赖的package包/类
@Override
public DeleteObjectsResult deleteObjects(DeleteObjectsRequest deleteObjectsRequest)
        throws AmazonClientException
{
    return null;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:7,代码来源:MockAmazonS3.java

示例12: deleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsResult; //导入依赖的package包/类
@Override
public DeleteObjectsResult deleteObjects(DeleteObjectsRequest deleteObjectsRequest) throws AmazonClientException,
    AmazonServiceException {
  // TODO Auto-generated method stub
  return null;
}
 
开发者ID:DemandCube,项目名称:Scribengin,代码行数:7,代码来源:AmazonS3Mock.java

示例13: deleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsResult; //导入依赖的package包/类
/**
 * Deletes the specified S3 objects in the specified S3 bucket.
 *
 * @param deleteObjectsRequest the request object containing all the options for deleting multiple objects in a specified bucket
 * @param s3Client the {@link AmazonS3} implementation to use
 *
 * @return the successful response to the delete object request
 */
public DeleteObjectsResult deleteObjects(DeleteObjectsRequest deleteObjectsRequest, AmazonS3 s3Client);
 
开发者ID:FINRAOS,项目名称:herd,代码行数:10,代码来源:S3Operations.java

示例14: deleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsResult; //导入依赖的package包/类
/**
 * Delete objects.
 *
 * @param bucketName the bucket name
 * @param keys the keys
 * @return the delete objects result
 * @throws AmazonClientException the amazon client exception
 * @throws AmazonServiceException the amazon service exception
 */
DeleteObjectsResult deleteObjects(final String bucketName, final List<KeyVersion> keys)
		throws AmazonClientException, AmazonServiceException;
 
开发者ID:abhinavmishra14,项目名称:aws-s3-utils,代码行数:12,代码来源:AwsS3IamService.java


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