attributes.put("azure.container", containerName); attributes.put("azure.primaryUri", blob.getSnapshotQualifiedUri().toString()); attributes.put("azure.etag", properties.getEtag()); attributes.put("azure.length", String.valueOf(length)); attributes.put("azure.timestamp", String.valueOf(properties.getLastModified()));
.contentType(properties.getContentType()) .contentLanguage(properties.getContentLanguage()) .etag(properties.getEtag()) .lastModifiedTime(properties.getLastModified().getTime()) .length(properties.getLength());
contentType = Strings.nullToEmpty(properties.getContentType()); contentMD5Header = Strings.nullToEmpty(properties.getContentMD5()); eTag = Strings.nullToEmpty(properties.getEtag());
attributes.setSize(blob.getProperties().getLength()); attributes.setModificationDate(blob.getProperties().getLastModified().getTime()); attributes.setETag(blob.getProperties().getEtag()); if(StringUtils.isNotBlank(blob.getProperties().getContentMD5())) { attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(blob.getProperties().getContentMD5()))));
contentType = Strings.nullToEmpty(properties.getContentType()); contentMD5Header = Strings.nullToEmpty(properties.getContentMD5()); eTag = Strings.nullToEmpty(properties.getEtag());
previousLeaseId = accessCondition.getLeaseID(); if (!accessCondition.verifyConditional(this.parentBlobRef.getProperties().getEtag(), this.parentBlobRef .getProperties().getLastModified())) { throw new StorageException(StorageErrorCode.CONDITION_FAILED.toString(), this.accessCondition = AccessCondition.generateIfMatchCondition(this.parentBlobRef.getProperties().getEtag()); this.accessCondition.setLeaseID(previousLeaseId);
attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(properties.getContentMD5())))); attributes.setETag(properties.getEtag()); return attributes;
previousLeaseId = accessCondition.getLeaseID(); if (!accessCondition.verifyConditional(this.parentBlobRef.getProperties().getEtag(), this.parentBlobRef .getProperties().getLastModified())) { throw new StorageException(StorageErrorCode.CONDITION_FAILED.toString(), this.accessCondition = AccessCondition.generateIfMatchCondition(this.parentBlobRef.getProperties().getEtag()); this.accessCondition.setLeaseID(previousLeaseId);
this.setLockedETag(blob.properties.getEtag()); this.setArePropertiesPopulated(true);
this.setLockedETag(blob.properties.getEtag()); this.setArePropertiesPopulated(true);
accessCondition = AccessCondition.generateIfNoneMatchCondition(blob1.getProperties().getEtag()); try { blob1.upload(srcStream, length, accessCondition, null, null); accessCondition = AccessCondition.generateIfMatchCondition(blob1.getProperties().getEtag()); blob1.upload(srcStream, length, accessCondition, null, null); CloudPageBlob blob2 = this.container.getPageBlobReference("blob2"); blob2.create(1024); accessCondition = AccessCondition.generateIfMatchCondition(blob1.getProperties().getEtag()); try { blob1.upload(srcStream, length, accessCondition, null, null); accessCondition = AccessCondition.generateIfNoneMatchCondition(blob2.getProperties().getEtag()); blob1.upload(srcStream, length, accessCondition, null, null);
accessCondition = AccessCondition.generateIfNoneMatchCondition(blob1.getProperties().getEtag()); try { blob1.upload(srcStream, length, accessCondition, null, null); accessCondition = AccessCondition.generateIfMatchCondition(blob1.getProperties().getEtag()); blob1.upload(srcStream, length, accessCondition, null, null); accessCondition = AccessCondition.generateIfMatchCondition(blob2.getProperties().getEtag()); try { blob1.upload(srcStream, length, accessCondition, null, null); accessCondition = AccessCondition.generateIfNoneMatchCondition(blob2.getProperties().getEtag()); blob1.upload(srcStream, length, accessCondition, null, null);
blob1.createOrReplace(); accessCondition = AccessCondition.generateIfNoneMatchCondition(blob1 .getProperties().getEtag()); try { blob1.upload(srcStream, length, accessCondition, null, null); .getProperties().getEtag()); blob1.upload(srcStream, length, accessCondition, null, null); blob2.createOrReplace(); accessCondition = AccessCondition.generateIfMatchCondition(blob1 .getProperties().getEtag()); try { blob1.upload(srcStream, length, accessCondition, null, null); .getProperties().getEtag()); blob1.upload(srcStream, length, accessCondition, null, null);
@Test public void testRetryOn304() throws StorageException, IOException, URISyntaxException { OperationContext operationContext = new OperationContext(); operationContext.getRetryingEventHandler().addListener(new StorageEvent<RetryingEvent>() { @Override public void eventOccurred(RetryingEvent eventArg) { fail("Request should not be retried."); } }); CloudBlobContainer container = BlobTestHelper.getRandomContainerReference(); try { container.create(); CloudBlockBlob blockBlobRef = (CloudBlockBlob) BlobTestHelper.uploadNewBlob(container, BlobType.BLOCK_BLOB, "originalBlob", 1024, null); AccessCondition accessCondition = AccessCondition.generateIfNoneMatchCondition(blockBlobRef.getProperties().getEtag()); blockBlobRef.download(new ByteArrayOutputStream(), accessCondition, null, operationContext); fail("Download should fail with a 304."); } catch (StorageException ex) { assertEquals("The condition specified using HTTP conditional header(s) is not met.", ex.getMessage()); } finally { container.deleteIfExists(); } }
assertFalse(source.getProperties().getEtag().equals(destination.getProperties().getEtag()));
BlobTestHelper.waitForCopy(destination); destination.downloadAttributes(); assertNotNull(destination.getProperties().getEtag());
public static void assertAreEqual(BlobProperties prop1, BlobProperties prop2) { if (prop1 == null) { assertNull(prop2); } else { assertNotNull(prop2); assertEquals(prop1.getBlobType(), prop2.getBlobType()); assertEquals(prop1.getCacheControl(), prop2.getCacheControl()); assertEquals(prop1.getContentDisposition(), prop2.getContentDisposition()); assertEquals(prop1.getContentEncoding(), prop2.getContentEncoding()); assertEquals(prop1.getContentLanguage(), prop2.getContentLanguage()); assertEquals(prop1.getContentMD5(), prop2.getContentMD5()); assertEquals(prop1.getContentType(), prop2.getContentType()); assertEquals(prop1.getEtag(), prop2.getEtag()); assertEquals(prop1.getLastModified(), prop2.getLastModified()); assertEquals(prop1.getLength(), prop2.getLength()); assertEquals(prop1.getPageBlobSequenceNumber(), prop2.getPageBlobSequenceNumber()); } }