/** * Sets the list of keys to delete from this bucket, clearing any existing * list of keys. * * @param keys * The list of keys to delete from this bucket * * @return this, to chain multiple calls togethers. */ public DeleteObjectsRequest withKeys(List<KeyVersion> keys) { setKeys(keys); return this; }
/** * Convenience method to specify a set of keys without versions. * * @see DeleteObjectsRequest#withKeys(List) */ public DeleteObjectsRequest withKeys(String... keys) { List<KeyVersion> keyVersions = new ArrayList<KeyVersion>(keys.length); for (String key : keys) { keyVersions.add(new KeyVersion(key)); } setKeys(keyVersions); return this; }
/** * Sets the list of keys to delete from this bucket, clearing any existing * list of keys. * * @param keys The list of keys to delete from this bucket * @return this, to chain multiple calls togethers. */ public DeleteObjectsRequest withKeys(List<KeyVersion> keys) { setKeys(keys); return this; }
/** * Convenience method to specify a set of keys without versions. * * @see DeleteObjectsRequest#withKeys(List) */ public DeleteObjectsRequest withKeys(String... keys) { final List<KeyVersion> keyVersions = new ArrayList<KeyVersion>(keys.length); for (final String key : keys) { keyVersions.add(new KeyVersion(key)); } setKeys(keyVersions); return this; }
/** * Sets the list of keys to delete from this bucket, clearing any existing * list of keys. * * @param keys The list of keys to delete from this bucket * @return this, to chain multiple calls togethers. */ public DeleteObjectsRequest withKeys(List<KeyVersion> keys) { setKeys(keys); return this; }
/** * Sets the list of keys to delete from this bucket, clearing any existing * list of keys. * * @param keys * The list of keys to delete from this bucket * * @return this, to chain multiple calls togethers. */ public DeleteObjectsRequest withKeys(List<KeyVersion> keys) { setKeys(keys); return this; }
/** * Convenience method to specify a set of keys without versions. * * @see DeleteObjectsRequest#withKeys(List) */ public DeleteObjectsRequest withKeys(String... keys) { List<KeyVersion> keyVersions = new ArrayList<KeyVersion>(keys.length); for (String key : keys) { keyVersions.add(new KeyVersion(key)); } setKeys(keyVersions); return this; }
/** * Convenience method to specify a set of keys without versions. * * @see DeleteObjectsRequest#withKeys(List) */ public DeleteObjectsRequest withKeys(String... keys) { final List<KeyVersion> keyVersions = new ArrayList<KeyVersion>(keys.length); for (final String key : keys) { keyVersions.add(new KeyVersion(key)); } setKeys(keyVersions); return this; }
static void multiObjectNonVersionedDelete(List<KeyVersion> keys) { // Multi-object delete by specifying only keys (no version ID). DeleteObjectsRequest multiObjectDeleteRequest = new DeleteObjectsRequest( bucketName).withQuiet(false); // Create request that include only object key names. List<KeyVersion> justKeys = new ArrayList<KeyVersion>(); for (KeyVersion key : keys) { justKeys.add(new KeyVersion(key.getKey())); } multiObjectDeleteRequest.setKeys(justKeys); // Execute DeleteObjects - Amazon S3 add delete marker for each object // deletion. The objects no disappear from your bucket (verify). DeleteObjectsResult delObjRes = null; try { delObjRes = s3Client.deleteObjects(multiObjectDeleteRequest); System.out.format("Successfully deleted all the %s items.\n", delObjRes.getDeletedObjects().size()); } catch (MultiObjectDeleteException mode) { printDeleteResults(mode); } }
multiObjectDeleteRequest.setKeys(keysSubList); try
@Override public void deleteAllMetadataRecords(String prefix) { checkArgument(null != prefix, "prefix should not be empty"); ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader( getClass().getClassLoader()); ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucket).withPrefix(addMetaKeyPrefix(prefix)); ObjectListing metaList = s3service.listObjects(listObjectsRequest); List<DeleteObjectsRequest.KeyVersion> deleteList = new ArrayList<DeleteObjectsRequest.KeyVersion>(); for (S3ObjectSummary s3ObjSumm : metaList.getObjectSummaries()) { deleteList.add(new DeleteObjectsRequest.KeyVersion(s3ObjSumm.getKey())); } if (deleteList.size() > 0) { DeleteObjectsRequest delObjsReq = new DeleteObjectsRequest(bucket); delObjsReq.setKeys(deleteList); s3service.deleteObjects(delObjsReq); } } finally { if (contextClassLoader != null) { Thread.currentThread().setContextClassLoader(contextClassLoader); } } }
multiObjectDeleteRequest.setKeys(keysSubList); try
@Override public void deleteAllMetadataRecords(String prefix) { checkArgument(null != prefix, "prefix should not be empty"); ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader( getClass().getClassLoader()); ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucket).withPrefix(addMetaKeyPrefix(prefix)); ObjectListing metaList = s3service.listObjects(listObjectsRequest); List<DeleteObjectsRequest.KeyVersion> deleteList = new ArrayList<DeleteObjectsRequest.KeyVersion>(); for (S3ObjectSummary s3ObjSumm : metaList.getObjectSummaries()) { deleteList.add(new DeleteObjectsRequest.KeyVersion(s3ObjSumm.getKey())); } if (deleteList.size() > 0) { DeleteObjectsRequest delObjsReq = new DeleteObjectsRequest(bucket); delObjsReq.setKeys(deleteList); s3service.deleteObjects(delObjsReq); } } finally { if (contextClassLoader != null) { Thread.currentThread().setContextClassLoader(contextClassLoader); } } }
DeleteObjectsRequest delObjsReq = new DeleteObjectsRequest( bucket); delObjsReq.setKeys(deleteList); s3service.deleteObjects(delObjsReq);
DeleteObjectsRequest delObjsReq = new DeleteObjectsRequest( bucket); delObjsReq.setKeys(deleteList); s3service.deleteObjects(delObjsReq);
return; multiObjectDeleteRequest.setKeys(keys);
public void delete() { checkState(isConfigured(), "client not configured."); if (temporaryPrefix == null) { return; } Iterable<S3ObjectSummary> objects = S3Objects.withPrefix(s3, bucket, temporaryPrefix); Iterable<List<S3ObjectSummary>> partition = Iterables.partition(objects, 1000); for (List<S3ObjectSummary> os : partition) { List<KeyVersion> keys = Lists.transform( os, new Function<S3ObjectSummary, KeyVersion>() { @Override public KeyVersion apply(S3ObjectSummary input) { KeyVersion k = new KeyVersion(input.getKey()); return k; } }); DeleteObjectsRequest deleteRequest = new DeleteObjectsRequest(bucket); deleteRequest.setKeys(keys); s3.deleteObjects(deleteRequest); } }
req.setKeys(keys); conn.deleteObjects(req);
delObjsReq.setKeys(deleteList); s3service.deleteObjects(delObjsReq);