@Test public void deleteObject() throws IOException { object.uploadObject(new byte[] {}); assertEquals(1, container.list().size()); object.delete(); assertEquals(0, container.list().size()); }
/** * Delete an object if it exists. * * @param object object handle to delete * @return true if object deletion was successful */ private boolean deleteObject(final StoredObject object) { try { object.delete(); return true; } catch (NotFoundException e) { LOG.debug("Object {} not found", object.getPath()); } return false; }
@Override public boolean deleteById(String fileId) throws IOException { try { StoredObject swiftObject = container.getObject(fileId); swiftObject.delete(); return true; } catch (NotFoundException e) { return false; } }
/** * Delete an arbitrary BlobPath from our store. * * @param path The blob path to delete */ @Override public void delete(BlobPath path) { String keyPath = path.buildAsString("/"); if (!keyPath.isEmpty()) { keyPath = keyPath + "/"; } StoredObject obj = swift().getObject(keyPath); if (obj.exists()) { obj.delete(); } }
@Test public void deleteObject() { expectStatusCode(204); object.delete(); }