Skip to content

Commit

Permalink
Merge pull request #4 from gcheng/London
Browse files Browse the repository at this point in the history
Support range MD5 for get Blob request.
  • Loading branch information
Albert Cheng committed Jul 27, 2012
2 parents 4ad59a4 + 8f8c6e3 commit a97379d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,9 @@ public GetBlobResult getBlob(String container, String blob, GetBlobOptions optio
builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId());
builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd());
builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition());
if (options.isComputeRangeMD5()) {
builder = addOptionalHeader(builder, "x-ms-range-get-content-md5", "true");
}

ClientResponse response = builder.get(ClientResponse.class);
ThrowIfNotSuccess(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,32 @@ public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception
// Assert
}

@Test
public void getBlobWithMD5Range() throws Exception {
// Arrange
Configuration config = createConfiguration();
BlobContract service = BlobService.create(config);
String expectedMd5 = "+zxkkqBt6HehE3r5suhS1w==";

// Act
String container = TEST_CONTAINER_FOR_BLOBS;
String blob = "test";
service.createPageBlob(container, blob, 4096);

GetBlobOptions options = new GetBlobOptions();
options = options.setRangeStart(50L);
options = options.setRangeEnd(200L);
options = options.setComputeRangeMD5(true);
GetBlobResult getBlobResult = service.getBlob(container, blob, options);

// Assert
assertNotNull(getBlobResult);
BlobProperties blobProperties = getBlobResult.getProperties();
String actualMd5 = blobProperties.getContentMD5();
assertEquals(expectedMd5, actualMd5);

}

@Test
public void getBlobPropertiesWorks() throws Exception {
// Arrange
Expand Down

0 comments on commit a97379d

Please sign in to comment.