@Test public void testAppendBlobUploadFromStream() throws StorageException, IOException, URISyntaxException { byte[] buffer = BlobTestHelper.getRandomBuffer(6 * 1024 * 1024); CloudAppendBlob blob = this.container.getAppendBlobReference("blob1"); blob.upload(new ByteArrayInputStream(buffer), buffer.length); blob.downloadAttributes(); assertEquals(6 * 1024 * 1024, blob.getProperties().getLength()); blob.upload(new ByteArrayInputStream(buffer), buffer.length); blob.downloadAttributes(); assertEquals(6 * 1024 * 1024, blob.getProperties().getLength()); blob.upload(new ByteArrayInputStream(buffer), buffer.length, null /* accessCondition */, null /* options */, null /* operationContext */); blob.downloadAttributes(); assertEquals(6 * 1024 * 1024, blob.getProperties().getLength()); }
@Test public void testAppendBlobAppendFromStream() throws StorageException, IOException, URISyntaxException { // Every time append a buffer that is bigger than a single block. byte[] buffer = BlobTestHelper.getRandomBuffer(6 * 1024 * 1024); CloudAppendBlob blob = this.container.getAppendBlobReference("blob1"); blob.createOrReplace(); blob.append(new ByteArrayInputStream(buffer), buffer.length); blob.downloadAttributes(); assertEquals(6 * 1024 * 1024, blob.getProperties().getLength()); blob.append(new ByteArrayInputStream(buffer), buffer.length); blob.downloadAttributes(); assertEquals(12 * 1024 * 1024, blob.getProperties().getLength()); blob.append(new ByteArrayInputStream(buffer), buffer.length, null /* accessCondition */, null /* options */, null /* operationContext */); blob.downloadAttributes(); assertEquals(18 * 1024 * 1024, blob.getProperties().getLength()); }
@Test public void testAppendBlobAppendFromStreamWithLength() throws StorageException, IOException, URISyntaxException { // Every time append a buffer that is bigger than a single block. byte[] buffer = BlobTestHelper.getRandomBuffer(6 * 1024 * 1024); CloudAppendBlob blob = this.container.getAppendBlobReference("blob1"); blob.createOrReplace(); blob.append(new ByteArrayInputStream(buffer), 5 * 1024 * 1024); blob.downloadAttributes(); assertEquals(5 * 1024 * 1024, blob.getProperties().getLength()); blob.append(new ByteArrayInputStream(buffer), 5 * 1024 * 1024); blob.downloadAttributes(); assertEquals(10 * 1024 * 1024, blob.getProperties().getLength()); blob.append(new ByteArrayInputStream(buffer), 5 * 1024 * 1024, null /* accessCondition */, null /* options */, null /* operationContext */); blob.downloadAttributes(); assertEquals(15 * 1024 * 1024, blob.getProperties().getLength()); } }
@Test public void testAppendBlobNamePlusEncodingTest() throws StorageException, URISyntaxException, IOException, InterruptedException { final int length = 1 * 1024; final CloudAppendBlob originalBlob = (CloudAppendBlob) BlobTestHelper.uploadNewBlob( this.container, BlobType.APPEND_BLOB, "a+b.txt", length, null); final CloudAppendBlob copyBlob = this.container.getAppendBlobReference(originalBlob.getName() + "copyed"); copyBlob.startCopy(originalBlob); BlobTestHelper.waitForCopy(copyBlob); copyBlob.downloadAttributes(); }
this.downloadAttributes(accessCondition, modifiedOptions, opContext);
this.downloadAttributes(accessCondition, options, opContext);
snapshotStream.toByteArray())); source.downloadAttributes(); snapshot.downloadAttributes(); assertFalse(source.getMetadata().get("Test") .equals(snapshot.getMetadata().get("Test"))); assertEquals(copyId, copy.getProperties().getCopyState().getCopyId()); copy.downloadAttributes(); BlobProperties prop1 = copy.getProperties(); BlobProperties prop2 = snapshot.getProperties();
copyStream.toByteArray())); copy.downloadAttributes(); source.downloadAttributes(); BlobProperties prop1 = copy.getProperties(); BlobProperties prop2 = source.getProperties();
source.downloadAttributes(); assertNotNull(copy.getProperties().getEtag()); assertFalse(source.getProperties().getEtag() copyStream.toByteArray())); copy.downloadAttributes(); BlobProperties prop1 = copy.getProperties(); BlobProperties prop2 = source.getProperties();
@Test public void testBlobUploadWithoutMD5Validation() throws URISyntaxException, StorageException, IOException { final String appendBlobName = BlobTestHelper .generateRandomBlobNameWithPrefix("testAppendBlob"); final CloudAppendBlob appendBlobRef = this.container .getAppendBlobReference(appendBlobName); final int length = 2 * 1024; ByteArrayInputStream srcStream = BlobTestHelper .getRandomDataStream(length); BlobRequestOptions options = new BlobRequestOptions(); options.setDisableContentMD5Validation(false); options.setStoreBlobContentMD5(false); appendBlobRef.upload(srcStream, length, null, options, null); appendBlobRef.downloadAttributes(); appendBlobRef.getProperties().setContentMD5("MDAwMDAwMDA="); appendBlobRef.uploadProperties(null, options, null); try { appendBlobRef.download(new ByteArrayOutputStream(), null, options, null); fail(); } catch (StorageException ex) { assertEquals(306, ex.getHttpStatusCode()); assertEquals("InvalidMd5", ex.getErrorCode()); } options.setDisableContentMD5Validation(true); appendBlobRef .download(new ByteArrayOutputStream(), null, options, null); }
BlobTestHelper.waitForCopy(copySas); copySas.downloadAttributes(); BlobProperties prop1 = copySas.getProperties(); BlobProperties prop2 = sasBlob.getProperties();
@Test public void testOpenOutputStreamNoArgs() throws URISyntaxException, StorageException { String blobName = BlobTestHelper .generateRandomBlobNameWithPrefix("testblob"); CloudAppendBlob appendBlob = this.container .getAppendBlobReference(blobName); try { appendBlob.openWriteExisting(); } catch (StorageException ex) { assertEquals("The specified blob does not exist.", ex.getMessage()); assertEquals(HttpURLConnection.HTTP_NOT_FOUND, ex.getHttpStatusCode()); } appendBlob.openWriteNew(); appendBlob.openWriteExisting(); CloudAppendBlob appendBlob2 = this.container .getAppendBlobReference(blobName); appendBlob2.downloadAttributes(); assertEquals(0, appendBlob2.getProperties().getLength()); assertEquals(BlobType.APPEND_BLOB, appendBlob2.getProperties().getBlobType()); }
appendBlobRef1.uploadProperties(); appendBlobRef1.downloadAttributes(null, options, null); BlobProperties props2 = appendBlobRef1.getProperties();