/** * Delete multiple objects in a bucket with a single request, with all details in the * (non-"quiet") result. * * @param bucketName * the name of the versioned bucket containing the object to be deleted. * @param objectNameAndVersions * information about one or more objects to delete, including at least the object's * key name and optionally the object's version. * both errors (if any) and a list of object successfully deleted * the key representing the object in S3. * @return MultipleDeleteResult * @throws S3ServiceException */ public MultipleDeleteResult deleteMultipleObjects(String bucketName, ObjectKeyAndVersion[] objectNameAndVersions) throws S3ServiceException { return deleteMultipleObjects(bucketName, objectNameAndVersions, false); }
/** * Delete multiple objects in a bucket with a single request, with all details in the * (non-"quiet") result. * * @param bucketName * the name of the versioned bucket containing the object to be deleted. * @param objectNameAndVersions * information about one or more objects to delete, including at least the object's * key name and optionally the object's version. * both errors (if any) and a list of object successfully deleted * the key representing the object in S3. * @return MultipleDeleteResult * @throws S3ServiceException */ public MultipleDeleteResult deleteMultipleObjects(String bucketName, ObjectKeyAndVersion[] objectNameAndVersions) throws S3ServiceException { return deleteMultipleObjects(bucketName, objectNameAndVersions, false); }
/** * Delete multiple objects in a bucket with a single request, with all details in the * (non-"quiet") result. * * @param bucketName * the name of the versioned bucket containing the object to be deleted. * @param keys * key names of objects to delete. * both errors (if any) and a list of object successfully deleted * the key representing the object in S3. * @return MultipleDeleteResult * @throws S3ServiceException */ public MultipleDeleteResult deleteMultipleObjects(String bucketName, String[] keys) throws S3ServiceException { ObjectKeyAndVersion[] objectKeyAndVersion = new ObjectKeyAndVersion[keys.length]; int i = 0; for (String key: keys) { objectKeyAndVersion[i++] = new ObjectKeyAndVersion(key); } return deleteMultipleObjects(bucketName, objectKeyAndVersion, false); }
/** * Delete multiple objects in a bucket with a single request, with all details in the * (non-"quiet") result. * * @param bucketName * the name of the versioned bucket containing the object to be deleted. * @param keys * key names of objects to delete. * both errors (if any) and a list of object successfully deleted * the key representing the object in S3. * @return MultipleDeleteResult * @throws S3ServiceException */ public MultipleDeleteResult deleteMultipleObjects(String bucketName, String[] keys) throws S3ServiceException { ObjectKeyAndVersion[] objectKeyAndVersion = new ObjectKeyAndVersion[keys.length]; int i = 0; for (String key: keys) { objectKeyAndVersion[i++] = new ObjectKeyAndVersion(key); } return deleteMultipleObjects(bucketName, objectKeyAndVersion, false); }
String[] ar = new String[al.size()]; ar = al.toArray(ar); bs3Service.deleteMultipleObjects(bucketName, ar); al = new ArrayList<String>(); System.out.print("."); bs3Service.deleteMultipleObjects(bucketName, (String[]) ar); al = new ArrayList<String>(); obj = bs3Service.listObjects(bucketName);
public void deleteAll(String path) { try { String priorLastKey = null; while(true) { StorageObjectsChunk chunk = m_s3service.listObjectsChunked(BUCKET, path, "?", CHUNK_SIZE, priorLastKey); m_logger.trace("ListObjects to delete: {}", path); inc(); StorageObject[] objects = chunk.getObjects(); if(objects.length == 0) break; String[] names = new String[objects.length]; for(int i = 0; i < objects.length; i++) { names[i] = objects[i].getKey(); } m_s3service.deleteMultipleObjects(BUCKET, names); m_logger.trace("DeleteObjects: {}", objects.length); // do not inc() because delete requests are not counted if(chunk.isListingComplete()) break; priorLastKey = chunk.getPriorLastKey(); } } catch (ServiceException e) { throw new RuntimeException(e); } }