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


Java KeyVersion类代码示例

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


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

示例1: convertToXmlByteArray

import com.amazonaws.services.s3.model.DeleteObjectsRequest.KeyVersion; //导入依赖的package包/类
/**
 * Converts the specified {@link DeleteObjectsRequest} object to an XML fragment that
 * can be sent to Amazon S3.
 *
 * @param rq
 *            The {@link DeleteObjectsRequest}
 */
public byte[] convertToXmlByteArray(DeleteObjectsRequest rq) throws SdkClientException {
    
    XmlWriter xml = new XmlWriter();
    xml.start("Delete");
    if ( rq.getQuiet() ) {
        xml.start("Quiet").value("true").end();
    }
    
    for (KeyVersion keyVersion : rq.getKeys()) {
        writeKeyVersion(xml, keyVersion);
    }

    xml.end();

    return xml.getBytes();
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:24,代码来源:MultiObjectDeleteXmlFactory.java

示例2: remove

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

示例3: main

import com.amazonaws.services.s3.model.DeleteObjectsRequest.KeyVersion; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException {
   System.out.println("WARNING: This will indiscriminately delete every object in a given bucket. This operation cannot be undone.");
   final String bucketName = prompt("Bucket");
   if (!"yes".equals(prompt("Are you sure you want to delete all objects in bucket " + bucketName + "? (type 'yes' to continue)"))) {
      System.out.println("Aborting...");
      return;
   }
   final TruncateBucket truncater = new TruncateBucket(bucketName);
   truncater.truncate();

   ObjectListing results;
   do {
      results = s3.listObjects(bucketName);
      final List<KeyVersion> keys = results.getObjectSummaries().stream()
            .map((k) -> new KeyVersion(k.getKey()))
            .collect(toList());
      final DeleteObjectsRequest deleteRequest = new DeleteObjectsRequest(bucketName).withKeys(keys);
      s3.deleteObjects(deleteRequest);
   } while (results.isTruncated());

}
 
开发者ID:awslabs,项目名称:aws-big-data-blog,代码行数:22,代码来源:TruncateBucket.java

示例4: writeKeyVersion

import com.amazonaws.services.s3.model.DeleteObjectsRequest.KeyVersion; //导入依赖的package包/类
private void writeKeyVersion(XmlWriter xml, KeyVersion keyVersion) {
    xml.start("Object");
    xml.start("Key").value(keyVersion.getKey()).end();
    if (keyVersion.getVersion() != null) {
        xml.start("VersionId").value(keyVersion.getVersion()).end();
    }
    xml.end();
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:9,代码来源:MultiObjectDeleteXmlFactory.java

示例5: deleteObjects

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

示例6: delete

import com.amazonaws.services.s3.model.DeleteObjectsRequest.KeyVersion; //导入依赖的package包/类
/**
 * Method delete all <i>objects</i> from <i>bucketName</i> in groups by 1000
 * elements
 * 
 * @param bucketName
 * @param objects
 */
public void delete(String bucketName, List<KeyVersion> objects) {
    ReactiveSeq.fromList(objects)
               .grouped(1000)
               .forEach(l -> {
                   DeleteObjectsRequest req = new DeleteObjectsRequest(
                                                                       bucketName);
                   req.setKeys(l.toList());
                   client.deleteObjects(req);
               });
}
 
开发者ID:aol,项目名称:micro-server,代码行数:18,代码来源:S3Utils.java

示例7: deleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsRequest.KeyVersion; //导入依赖的package包/类
@Test
public void deleteObjects() {
    AmazonS3Client client = mock(AmazonS3Client.class);
    S3Utils utils = new S3Utils(
                                client, null, null, false, null);
    List<KeyVersion> keys = new ArrayList<>();
    for (int i = 0; i < 2000; i++) {
        keys.add(new KeyVersion(
                                ""));
    }

    utils.delete("", keys);

    verify(client, times(2)).deleteObjects(any());
}
 
开发者ID:aol,项目名称:micro-server,代码行数:16,代码来源:S3UtilsTest.java

示例8: deleteObjects

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

示例9: testDeleteObjects

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

示例10: deleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsRequest.KeyVersion; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * The stub does not currently support versions so this stub only supports full deletes of the objects. Passing in a
 * list of KeyVersion specs to be deleted will completely delete those objects from the stubs.
 *
 * @see com.amazonaws.services.s3.AmazonS3#deleteObjects(com.amazonaws.services.s3.model.DeleteObjectsRequest)
 */
@Override
public DeleteObjectsResult deleteObjects(final DeleteObjectsRequest deleteObjectsRequest) {
  final List<DeleteObjectsResult.DeletedObject> deletedObjects = new ArrayList<DeletedObject>();
  final BucketInfo bucket = getBucketInfo(deleteObjectsRequest.getBucketName());
  for (final KeyVersion key : deleteObjectsRequest.getKeys()) {
    final boolean found = bucket.deleteObject(key.getKey());
    if (!deleteObjectsRequest.getQuiet() && found) {
      final DeleteObjectsResult.DeletedObject result = new DeleteObjectsResult.DeletedObject();
      result.setKey(key.getKey());
      deletedObjects.add(result);
    }
  }
  return new DeleteObjectsResult(deletedObjects);
}
 
开发者ID:bizo,项目名称:aws-java-sdk-stubs,代码行数:23,代码来源:AmazonS3Stub.java

示例11: deleteEntities

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

示例12: deleteObjects

import com.amazonaws.services.s3.model.DeleteObjectsRequest.KeyVersion; //导入依赖的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.DeleteObjectsRequest.KeyVersion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。