/** * Downloads the contents of a file to a stream. * * @param offset * A <code>long</code> which represents the offset to use as the starting point for the source. * @param length * A <code>Long</code> which represents the number of bytes to read or <code>null</code>. * @param outStream * An <code>{@link OutputStream}</code> object that represents the target stream. * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public final void downloadRange(final long offset, final Long length, final OutputStream outStream) throws StorageException { this.downloadRange(offset, length, outStream, null /* accessCondition */, null /* options */, null /* opContext */); }
/** * Downloads the contents of a file to a stream. * * @param offset * A <code>long</code> which represents the offset to use as the starting point for the source. * @param length * A <code>Long</code> which represents the number of bytes to read or <code>null</code>. * @param outStream * An <code>{@link OutputStream}</code> object that represents the target stream. * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public final void downloadRange(final long offset, final Long length, final OutputStream outStream) throws StorageException { this.downloadRange(offset, length, outStream, null /* accessCondition */, null /* options */, null /* opContext */); }
file.downloadRange(0, new Long(0), fileStream); file.downloadRange(0, new Long(1024), fileStream); assertEquals(fileStream.size(), 1024); FileTestHelper.assertStreamsAreEqualAtIndex(new ByteArrayInputStream(fileStream.toByteArray()), wholeFile, 0, file.downloadRange(1024, new Long(0), fileStream); file2.downloadRange(1024, new Long(1024), fileStream2); FileTestHelper.assertStreamsAreEqualAtIndex(new ByteArrayInputStream(fileStream2.toByteArray()), wholeFile, 1024, 1024, 1024, 2 * 1024);
@Test @Category({ DevFabricTests.class, DevStoreTests.class }) public void testVerifyTransactionalMD5ValidationMissingOverallMD5() throws URISyntaxException, StorageException, IOException { final String fileName = FileTestHelper.generateRandomFileName(); final CloudFile fileRef = this.share.getRootDirectoryReference().getFileReference(fileName); final int length = 3*1024; ByteArrayInputStream srcStream = BlobTestHelper.getRandomDataStream(length); FileRequestOptions options = new FileRequestOptions(); options.setDisableContentMD5Validation(true); options.setStoreFileContentMD5(false); fileRef.upload(srcStream, length, null, options, null); options.setDisableContentMD5Validation(false); options.setStoreFileContentMD5(true); options.setUseTransactionalContentMD5(true); final CloudFile fileRef2 = this.share.getRootDirectoryReference().getFileReference(fileName); fileRef2.downloadRange(1024, (long)1024, new ByteArrayOutputStream(), null, options, null); assertNull(fileRef2.getProperties().getContentMD5()); }