/** * Downloads a range of bytes from the blob to the given byte buffer. * * @param buffer * A <code>byte</code> array which represents the buffer to which the blob bytes are downloaded. * @param bufferOffset * An <code>int</code> which represents the byte offset to use as the starting point for the target. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public final int downloadToByteArray(final byte[] buffer, final int bufferOffset) throws StorageException { return this .downloadToByteArray(buffer, bufferOffset, null /* accessCondition */, null /* options */, null /* opContext */); }
/** * Downloads a range of bytes from the blob to the given byte buffer. * * @param buffer * A <code>byte</code> array which represents the buffer to which the blob bytes are downloaded. * @param bufferOffset * An <code>int</code> which represents the byte offset to use as the starting point for the target. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public final int downloadToByteArray(final byte[] buffer, final int bufferOffset) throws StorageException { return this .downloadToByteArray(buffer, bufferOffset, null /* accessCondition */, null /* options */, null /* opContext */); }
byte[] data = new byte[(int) length]; try { b.downloadToByteArray(data, 0); } catch (StorageException e) { throw new IOException(e);
byte[] data = new byte[(int) length]; try { b.downloadToByteArray(data, 0); } catch (StorageException e) { throw new IOException(e);
HashMap<String, String> md = bi.getMetadata(); byte[] nm = new byte[(int) bi.getProperties().getLength()]; bi.downloadToByteArray(nm, 0, null, null, opContext); boolean encrypt = Boolean.parseBoolean(md.get("encrypt")); if (encrypt) {
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]); } } }
blob.downloadToByteArray(resultBuffer, 1024); fail();