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); }
assertEquals(metadata.getName(), object.getProperties().getName()); 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); assertEquals(metadata.getMetadata().entrySet().size(), 1); assertEquals(metadata.getMetadata().get("mykey"), "metadata-value"); assertEquals(getBlob.getProperties().getMetadata().get("new_metadata_1"), "value-1"); assertEquals(getBlob.getProperties().getMetadata().get("new_metadata_2"), "value-2"); assertEquals(metadata.getMetadata().entrySet().size(), 1); assertEquals(metadata.getMetadata().get("mykey"), "metadata-value"); .maxResults(1).includeMetadata()); assertEquals(response.size(), 1); assertEquals(Iterables.getOnlyElement(response).getName(), object.getProperties().getName()); assertEquals(Iterables.getOnlyElement(response).getMetadata().size(), 2); assertEquals(Iterables.getOnlyElement(response).getMetadata().get("new_metadata_1"), "value-1"); assertEquals(Iterables.getOnlyElement(response).getMetadata().get("new_metadata_2"), "value-2");
@Override public List<MultipartUpload> listMultipartUploads(String container) { ImmutableList.Builder<MultipartUpload> builder = ImmutableList.builder(); String marker = null; while (true) { ListBlobsOptions options = new ListBlobsOptions().include(EnumSet.of(ListBlobsInclude.UNCOMMITTEDBLOBS)); if (marker != null) { options.marker(marker); } ListBlobsResponse response = sync.listBlobs(container, options); for (BlobProperties properties : response) { // only uncommitted blobs lack ETags if (properties.getETag() != null) { continue; } // TODO: bogus uploadId String uploadId = UUID.randomUUID().toString(); builder.add(MultipartUpload.create(properties.getContainer(), properties.getName(), uploadId, null, null)); } marker = response.getNextMarker(); if (marker == null) { break; } } return builder.build(); }
/** *{@inheritDoc} */ @Override public int compareTo(BlobProperties o) { return (this == o) ? 0 : getName().compareTo(o.getName()); }
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); } }
assertEquals(metadata.getContentMetadata().getContentType(), "text/plain"); assertEquals(metadata.getETag(), newEtag); assertEquals(metadata.getMetadata().entrySet().size(), 1); assertEquals(metadata.getMetadata().get("mykey"), "metadata-value"); assertEquals(metadata.getMetadata().entrySet().size(), 1); assertEquals(metadata.getMetadata().get("mykey"), "metadata-value"); .maxResults(1).includeMetadata()); assertEquals(response.size(), 1); assertEquals(Iterables.getOnlyElement(response).getName(), object.getProperties().getName()); assertEquals(Iterables.getOnlyElement(response).getMetadata(), ImmutableMap.of("mykey", "metadata-value"));
@Override public List<MultipartUpload> listMultipartUploads(String container) { ImmutableList.Builder<MultipartUpload> builder = ImmutableList.builder(); String marker = null; while (true) { ListBlobsOptions options = new ListBlobsOptions().include(EnumSet.of(ListBlobsInclude.UNCOMMITTEDBLOBS)); if (marker != null) { options.marker(marker); } ListBlobsResponse response = sync.listBlobs(container, options); for (BlobProperties properties : response) { // only uncommitted blobs lack ETags if (properties.getETag() != null) { continue; } // TODO: bogus uploadId String uploadId = UUID.randomUUID().toString(); builder.add(MultipartUpload.create(properties.getContainer(), properties.getName(), uploadId, null, null)); } marker = response.getNextMarker(); if (marker == null) { break; } } return builder.build(); }
/** *{@inheritDoc} */ @Override public int compareTo(BlobProperties o) { return (this == o) ? 0 : getName().compareTo(o.getName()); }
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); }
/** *{@inheritDoc} */ public int compareTo(BlobProperties o) { return (this == o) ? 0 : getName().compareTo(o.getName()); }
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); }
/** *{@inheritDoc} */ @Override public int compareTo(BlobProperties o) { return (this == o) ? 0 : getName().compareTo(o.getName()); }
@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); }
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); }
/** *{@inheritDoc} */ public int compareTo(BlobProperties o) { return (this == o) ? 0 : getName().compareTo(o.getName()); }
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); }
/** *{@inheritDoc} */ @Override public int compareTo(BlobProperties o) { return (this == o) ? 0 : getName().compareTo(o.getName()); }