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.getContentMetadata().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 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.getContentMetadata().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 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.getContentMetadata().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 MutableBlobPropertiesImpl(BlobProperties from) { this.contentMetadata = new BaseMutableContentMetadata(); this.name = from.getName(); this.container = from.getContainer(); this.url = from.getUrl(); this.lastModified = from.getLastModified(); this.eTag = from.getETag(); this.metadata.putAll(from.getMetadata()); HttpUtils.copy(from.getContentMetadata(), this.contentMetadata); }
public MutableBlobPropertiesImpl(BlobProperties from) { this.contentMetadata = new BaseMutableContentMetadata(); this.name = from.getName(); this.container = from.getContainer(); this.url = from.getUrl(); this.lastModified = from.getLastModified(); this.eTag = from.getETag(); this.metadata.putAll(from.getMetadata()); HttpUtils.copy(from.getContentMetadata(), this.contentMetadata); }
public MutableBlobPropertiesImpl(BlobProperties from) { this.contentMetadata = new BaseMutableContentMetadata(); this.name = from.getName(); this.container = from.getContainer(); this.url = from.getUrl(); this.lastModified = from.getLastModified(); this.eTag = from.getETag(); this.metadata.putAll(from.getMetadata()); HttpUtils.copy(from.getContentMetadata(), this.contentMetadata); }
public MutableBlobPropertiesImpl(BlobProperties from) { this.contentMetadata = new BaseMutableContentMetadata(); this.name = from.getName(); this.container = from.getContainer(); this.url = from.getUrl(); this.lastModified = from.getLastModified(); this.eTag = from.getETag(); this.metadata.putAll(from.getMetadata()); HttpUtils.copy(from.getContentMetadata(), this.contentMetadata); }
public MutableBlobPropertiesImpl(BlobProperties from) { this.contentMetadata = new BaseMutableContentMetadata(); this.name = from.getName(); this.container = from.getContainer(); this.url = from.getUrl(); this.lastModified = from.getLastModified(); this.eTag = from.getETag(); this.metadata.putAll(from.getMetadata()); HttpUtils.copy(from.getContentMetadata(), this.contentMetadata); }
public MutableBlobMetadata apply(BlobProperties from) { if (from == null) return null; MutableBlobMetadata to = new MutableBlobMetadataImpl(); HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata()); to.setUserMetadata(from.getMetadata()); to.setETag(from.getETag()); to.setLastModified(from.getLastModified()); to.setName(from.getName()); to.setContainer(from.getContainer()); to.setUri(from.getUrl()); if (from.getContainer() != null) try { PublicAccess containerAcl = containerAcls.getUnchecked(from.getContainer()); if (containerAcl != PublicAccess.PRIVATE) to.setPublicUri(from.getUrl()); } catch (CacheLoader.InvalidCacheLoadException e) { // nulls not permitted from cache loader } if (to.getContentMetadata() != null && to.getContentMetadata().getContentType() != null && to.getContentMetadata().getContentType().equals("application/directory")) { to.setType(StorageType.FOLDER); } else { to.setType(StorageType.BLOB); } to.setSize(from.getContentMetadata().getContentLength()); return to; } }
return null; MutableBlobMetadata to = new MutableBlobMetadataImpl(); HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata()); to.setUserMetadata(from.getMetadata()); to.setETag(from.getETag()); to.setType(StorageType.BLOB); to.setSize(from.getContentMetadata().getContentLength()); AccessTier tier = from.getTier(); to.setTier((tier != null ? tier : AccessTier.HOT).toTier());
@Test(timeOut = 5 * 60 * 1000, dependsOnMethods = { "testCreateContainer" }) public void testSetBlobProperties() throws Exception { String blobName = "blob-name"; ByteSource byteSource = TestUtils.randomByteSource().slice(0, 1024); String contentDisposition = "attachment; filename=photo.jpg"; String contentEncoding = "compress"; String contentLanguage = "en"; String contentType = "audio/ogg"; // create blob AzureBlob object = getApi().newBlob(); object.getProperties().setName(blobName); object.setPayload(byteSource.read()); getApi().putBlob(privateContainer, object); // set properties getApi().setBlobProperties(privateContainer, blobName, ContentMetadataBuilder.create() .contentDisposition(contentDisposition) .contentEncoding(contentEncoding) .contentLanguage(contentLanguage) .contentType(contentType) .build()); // get properties BlobProperties properties = getApi().getBlobProperties(privateContainer, blobName); ContentMetadata contentMetadata = properties.getContentMetadata(); assertThat(contentMetadata.getContentDisposition()).isEqualTo(contentDisposition); assertThat(contentMetadata.getContentEncoding()).isEqualTo(contentEncoding); assertThat(contentMetadata.getContentLanguage()).isEqualTo(contentLanguage); assertThat(contentMetadata.getContentType()).isEqualTo(contentType); }
assertEquals(metadata.getContentMetadata().getContentLength(), Long.valueOf(data.length())); assertEquals(metadata.getContentMetadata().getContentType(), "text/plain"); assertEquals(base16().lowerCase().encode(metadata.getContentMetadata().getContentMD5()), base16().lowerCase().encode(object.getProperties().getContentMetadata().getContentMD5())); assertEquals(metadata.getETag(), newEtag);
public MutableBlobMetadata apply(BlobProperties from) { if (from == null) return null; MutableBlobMetadata to = new MutableBlobMetadataImpl(); HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata()); to.setUserMetadata(from.getMetadata()); to.setETag(from.getETag()); to.setLastModified(from.getLastModified()); to.setName(from.getName()); to.setContainer(from.getContainer()); to.setUri(from.getUrl()); if (from.getContainer() != null) try { PublicAccess containerAcl = containerAcls.getUnchecked(from.getContainer()); if (containerAcl != PublicAccess.PRIVATE) to.setPublicUri(from.getUrl()); } catch (CacheLoader.InvalidCacheLoadException e) { // nulls not permitted from cache loader } String directoryName = ifDirectoryReturnName.execute(to); if (directoryName != null) { to.setName(directoryName); to.setType(StorageType.RELATIVE_PATH); } else { to.setType(StorageType.BLOB); } return to; } }
assertEquals(metadata.getContentMetadata().getContentType(), "text/plain");
public MutableBlobMetadata apply(BlobProperties from) { if (from == null) return null; MutableBlobMetadata to = new MutableBlobMetadataImpl(); HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata()); to.setUserMetadata(from.getMetadata()); to.setETag(from.getETag()); to.setLastModified(from.getLastModified()); to.setName(from.getName()); to.setContainer(from.getContainer()); to.setUri(from.getUrl()); if (from.getContainer() != null) try { PublicAccess containerAcl = containerAcls.getUnchecked(from.getContainer()); if (containerAcl != PublicAccess.PRIVATE) to.setPublicUri(from.getUrl()); } catch (CacheLoader.InvalidCacheLoadException e) { // nulls not permitted from cache loader } String directoryName = ifDirectoryReturnName.execute(to); if (directoryName != null) { to.setName(directoryName); to.setType(StorageType.RELATIVE_PATH); } else { to.setType(StorageType.BLOB); } return to; } }
public MutableBlobMetadata apply(BlobProperties from) { if (from == null) return null; MutableBlobMetadata to = new MutableBlobMetadataImpl(); HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata()); to.setUserMetadata(from.getMetadata()); to.setETag(from.getETag()); to.setLastModified(from.getLastModified()); to.setName(from.getName()); to.setContainer(from.getContainer()); to.setUri(from.getUrl()); if (from.getContainer() != null) try { PublicAccess containerAcl = containerAcls.getUnchecked(from.getContainer()); if (containerAcl != PublicAccess.PRIVATE) to.setPublicUri(from.getUrl()); } catch (CacheLoader.InvalidCacheLoadException e) { // nulls not permitted from cache loader } String directoryName = ifDirectoryReturnName.execute(to); if (directoryName != null) { to.setName(directoryName); to.setType(StorageType.RELATIVE_PATH); } else { to.setType(StorageType.BLOB); } return to; } }