public static BlobRequestOptions withMD5Checking() { BlobRequestOptions options = new BlobRequestOptions(); options.setUseTransactionalContentMD5(true); return options; } }
private BlobRequestOptions getDownloadOptions() { BlobRequestOptions options = new BlobRequestOptions(); options.setRetryPolicyFactory( new RetryExponentialRetry(minBackoff, deltaBackoff, maxBackoff, maxRetries)); options.setUseTransactionalContentMD5(getUseTransactionalContentMD5()); return options; }
private BlobRequestOptions getUploadOptions() { BlobRequestOptions options = new BlobRequestOptions(); options.setStoreBlobContentMD5(sessionConfiguration.getBoolean( KEY_STORE_BLOB_MD5, false)); options.setUseTransactionalContentMD5(getUseTransactionalContentMD5()); options.setConcurrentRequestCount(concurrentWrites); options.setRetryPolicyFactory(new RetryExponentialRetry(minBackoff, deltaBackoff, maxBackoff, maxRetries)); return options; }
protected static void doDownloadTest(CloudBlob blob, int blobSize, int bufferSize, int bufferOffset) throws StorageException, IOException { final Random randGenerator = new Random(); final byte[] buffer = new byte[blobSize]; randGenerator.nextBytes(buffer); byte[] resultBuffer = new byte[bufferSize]; BlobRequestOptions options = new BlobRequestOptions(); if (blob.getClass() == CloudBlockBlob.class) { options.setUseTransactionalContentMD5(true); } blob.upload(new ByteArrayInputStream(buffer), buffer.length); blob.downloadToByteArray(resultBuffer, bufferOffset, null, options, null); for (int i = 0; i < blob.getProperties().getLength(); i++) { assertEquals(buffer[i], resultBuffer[bufferOffset + i]); } if (bufferOffset + blobSize < bufferSize) { for (int k = bufferOffset + blobSize; k < bufferSize; k++) { assertEquals(0, resultBuffer[k]); } } }
/** * Creates an instance of the <code>BlobRequestOptions</code> class by copying values from another * <code>BlobRequestOptions</code> instance. * * @param other * A {@link BlobRequestOptions} object which represents the blob request options to copy. */ public BlobRequestOptions(final BlobRequestOptions other) { super(other); if (other != null) { this.setAbsorbConditionalErrorsOnRetry(other.getAbsorbConditionalErrorsOnRetry()); this.setConcurrentRequestCount(other.getConcurrentRequestCount()); this.setUseTransactionalContentMD5(other.getUseTransactionalContentMD5()); this.setStoreBlobContentMD5(other.getStoreBlobContentMD5()); this.setDisableContentMD5Validation(other.getDisableContentMD5Validation()); this.setSingleBlobPutThresholdInBytes(other.getSingleBlobPutThresholdInBytes()); } }
/** * Creates an instance of the <code>BlobRequestOptions</code> class by copying values from another * <code>BlobRequestOptions</code> instance. * * @param other * A {@link BlobRequestOptions} object which represents the blob request options to copy. */ public BlobRequestOptions(final BlobRequestOptions other) { super(other); if (other != null) { this.setAbsorbConditionalErrorsOnRetry(other.getAbsorbConditionalErrorsOnRetry()); this.setConcurrentRequestCount(other.getConcurrentRequestCount()); this.setUseTransactionalContentMD5(other.getUseTransactionalContentMD5()); this.setStoreBlobContentMD5(other.getStoreBlobContentMD5()); this.setDisableContentMD5Validation(other.getDisableContentMD5Validation()); this.setSingleBlobPutThresholdInBytes(other.getSingleBlobPutThresholdInBytes()); this.setEncryptionPolicy(other.getEncryptionPolicy()); this.setValidateEncryptionPolicy(other.getValidateEncryptionPolicy()); } }
modifiedOptions.setUseTransactionalContentMD5(false);
modifiedOptions.setUseTransactionalContentMD5(false);
/** * Populates any null fields in the first requestOptions object with values from the second requestOptions object. */ private static void populateRequestOptions(BlobRequestOptions modifiedOptions, final BlobRequestOptions clientOptions, final boolean setStartTime) { RequestOptions.populateRequestOptions(modifiedOptions, clientOptions, setStartTime); if (modifiedOptions.getAbsorbConditionalErrorsOnRetry() == null) { modifiedOptions.setAbsorbConditionalErrorsOnRetry(clientOptions.getAbsorbConditionalErrorsOnRetry()); } if (modifiedOptions.getConcurrentRequestCount() == null) { modifiedOptions.setConcurrentRequestCount(clientOptions.getConcurrentRequestCount()); } if (modifiedOptions.getSingleBlobPutThresholdInBytes() == null) { modifiedOptions.setSingleBlobPutThresholdInBytes(clientOptions.getSingleBlobPutThresholdInBytes()); } if (modifiedOptions.getUseTransactionalContentMD5() == null) { modifiedOptions.setUseTransactionalContentMD5(clientOptions.getUseTransactionalContentMD5()); } if (modifiedOptions.getStoreBlobContentMD5() == null) { modifiedOptions.setStoreBlobContentMD5(clientOptions.getStoreBlobContentMD5()); } if (modifiedOptions.getDisableContentMD5Validation() == null) { modifiedOptions.setDisableContentMD5Validation(clientOptions.getDisableContentMD5Validation()); } }
@Test @Category({ DevFabricTests.class, DevStoreTests.class }) public void testVerifyTransactionalMD5ValidationMissingOverallMD5() throws URISyntaxException, StorageException, IOException { final String blockBlobName = BlobTestHelper.generateRandomBlobNameWithPrefix("testBlockBlob"); final CloudBlockBlob blockBlobRef = this.container.getBlockBlobReference(blockBlobName); final int length = 2 * 1024 * 1024; ByteArrayInputStream srcStream = BlobTestHelper.getRandomDataStream(length); BlobRequestOptions options = new BlobRequestOptions(); options.setSingleBlobPutThresholdInBytes(1024*1024); options.setDisableContentMD5Validation(true); options.setStoreBlobContentMD5(false); blockBlobRef.upload(srcStream, -1, null, options, null); options.setDisableContentMD5Validation(false); options.setStoreBlobContentMD5(true); options.setUseTransactionalContentMD5(true); final CloudBlockBlob blockBlobRef2 = this.container.getBlockBlobReference(blockBlobName); blockBlobRef2.downloadRange(1024, (long)1024, new ByteArrayOutputStream(), null, options, null); assertNull(blockBlobRef2.getProperties().getContentMD5()); }
modifiedOptions.setUseTransactionalContentMD5(clientOptions.getUseTransactionalContentMD5());