public void testBlobMetadata_withDefaultMetadata() throws IOException { String BLOB_KEY = TestUtils.createRandomBlobKey(null, null); // create the blob TestUtils.createBlobsInContainer(CONTAINER_NAME, BLOB_KEY); BlobMetadata metadata = blobStore.blobMetadata(CONTAINER_NAME, BLOB_KEY); assertNotNull(metadata, "Metadata null"); assertEquals(metadata.getName(), BLOB_KEY, "Wrong blob name"); assertEquals(metadata.getType(), StorageType.BLOB, "Wrong blob type"); assertEquals( metadata.getContentMetadata().getContentType(), "application/unknown", "Wrong blob content-type"); assertEquals( base16().lowerCase().encode(metadata.getContentMetadata().getContentMD5()), metadata.getETag(), "Wrong blob MD5"); assertEquals(metadata.getLocation(), null, "Wrong blob location"); assertEquals(metadata.getProviderId(), null, "Wrong blob provider id"); assertEquals(metadata.getUri(), null, "Wrong blob URI"); assertNotNull(metadata.getUserMetadata(), "No blob UserMetadata"); assertEquals(metadata.getUserMetadata().size(), 0, "Wrong blob UserMetadata"); // metadata.getLastModified() File file = new File(TARGET_CONTAINER_NAME, BLOB_KEY); assertEquals( metadata.getContentMetadata().getContentLength(), Long.valueOf(file.length()), "Wrong blob size"); }
public boolean execute(String containerName, Object value, ListContainerOptions options) { try { byte[] toSearch = objectMD5.apply(value); for (BlobMetadata metadata : getAllBlobMetadata.execute(containerName, options)) { BlobProperties properties = client.getBlobProperties(containerName, metadata.getName()); if (Arrays.equals(toSearch, properties.getContentMD5())) return true; } return false; } catch (Exception e) { Throwables.propagateIfPossible(e, BlobRuntimeException.class); throw new BlobRuntimeException( String.format( "Error searching for ETAG of value: [%2$s] in container:%1$s", containerName, value), e); } }
public int compareTo(BlobMetadata o) { if (getName() == null) return -1; return (this == o) ? 0 : getName().compareTo(o.getName()); }