descriptor = new StreamMd5AndLength(); if (calculateMD5) { try { descriptor.setDigest(MessageDigest.getInstance("MD5")); descriptor.setMd5(null); descriptor.getDigest().update(retrievedBuff, 0, count); descriptor.setLength(descriptor.getLength() + count); descriptor.setCurrentOperationByteCount(descriptor.getCurrentOperationByteCount() + count); nextCopy = (int) Math.min(retrievedBuff.length, writeLength - descriptor.getLength()); count = sourceStream.read(retrievedBuff, 0, nextCopy);
@Override public void setHeaders(HttpURLConnection connection, Void parentObject, OperationContext context) { connection.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, descriptor.getMd5()); }
final StreamMd5AndLength retVal = new StreamMd5AndLength(); int count = -1; final byte[] retrievedBuff = new byte[Constants.BUFFER_COPY_LENGTH]; int nextCopy = (int) Math.min(retrievedBuff.length, writeLength - retVal.getLength()); count = sourceStream.read(retrievedBuff, 0, nextCopy); digest.update(retrievedBuff, 0, count); retVal.setLength(retVal.getLength() + count); if (retVal.getLength() > abandonLength) { retVal.setLength(-1); retVal.setMd5(null); break; nextCopy = (int) Math.min(retrievedBuff.length, writeLength - retVal.getLength()); count = sourceStream.read(retrievedBuff, 0, nextCopy); if (retVal.getLength() != -1 && calculateMD5) { retVal.setMd5(Base64.encode(digest.digest())); if (retVal.getLength() != -1 && writeLength > 0) { retVal.setLength(Math.min(retVal.getLength(), writeLength));
StreamMd5AndLength descriptor = new StreamMd5AndLength(); descriptor.setLength(length); if (descriptor.getLength() > 4 * Constants.MB) { throw new IllegalArgumentException(SR.STREAM_LENGTH_GREATER_THAN_4MB); StorageRequest<CloudBlobClient, CloudAppendBlob, Long> appendBlockImpl = appendBlockImpl(descriptor.getMd5(), bufferedStreamReference, descriptor.getLength(), accessCondition, options, opContext); return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, appendBlockImpl, options.getRetryPolicyFactory(), opContext);
@Override public void signRequest(HttpURLConnection connection, ServiceClient client, OperationContext context) throws Exception { if (signAsTable) { StorageRequest.signTableRequest(connection, client, descriptor.getLength(), context); } else { StorageRequest.signBlobQueueAndFileRequest(connection, client, descriptor.getLength(), context); } }
StreamMd5AndLength descriptor = new StreamMd5AndLength(); descriptor.setLength(length); if (descriptor.getLength() > 4 * Constants.MB) { throw new IllegalArgumentException(SR.STREAM_LENGTH_GREATER_THAN_4MB); this.uploadBlockInternal(blockId, descriptor.getMd5(), bufferedStreamReference, descriptor.getLength(), accessCondition, options, opContext);
final StreamMd5AndLength retVal = new StreamMd5AndLength(); int count = -1; final byte[] retrievedBuff = new byte[Constants.BUFFER_COPY_LENGTH]; int nextCopy = (int) Math.min(retrievedBuff.length, writeLength - retVal.getLength()); count = sourceStream.read(retrievedBuff, 0, nextCopy); digest.update(retrievedBuff, 0, count); retVal.setLength(retVal.getLength() + count); if (retVal.getLength() > abandonLength) { retVal.setLength(-1); retVal.setMd5(null); break; nextCopy = (int) Math.min(retrievedBuff.length, writeLength - retVal.getLength()); count = sourceStream.read(retrievedBuff, 0, nextCopy); if (retVal.getLength() != -1 && calculateMD5) { retVal.setMd5(Base64.encode(digest.digest())); if (retVal.getLength() != -1 && writeLength > 0) { retVal.setLength(Math.min(retVal.getLength(), writeLength));
@Override public void signRequest(HttpURLConnection connection, ServiceClient client, OperationContext context) throws Exception { if (signAsTable) { StorageRequest.signTableRequest(connection, client, descriptor.getLength(), context); } else { StorageRequest.signBlobQueueAndFileRequest(connection, client, descriptor.getLength(), context); } }
descriptor = new StreamMd5AndLength(); if (calculateMD5) { try { descriptor.setDigest(MessageDigest.getInstance("MD5")); descriptor.setMd5(null); descriptor.getDigest().update(retrievedBuff, 0, count); descriptor.setLength(descriptor.getLength() + count); descriptor.setCurrentOperationByteCount(descriptor.getCurrentOperationByteCount() + count); nextCopy = (int) Math.min(retrievedBuff.length, writeLength - descriptor.getLength()); count = sourceStream.read(retrievedBuff, 0, nextCopy);
StreamMd5AndLength descriptor = new StreamMd5AndLength(); descriptor.setLength(length); if (descriptor.getLength() > 4 * Constants.MB) { throw new IllegalArgumentException(SR.STREAM_LENGTH_GREATER_THAN_4MB); StorageRequest<CloudBlobClient, CloudAppendBlob, Long> appendBlockImpl = appendBlockImpl(descriptor.getMd5(), bufferedStreamReference, descriptor.getLength(), accessCondition, options, opContext); return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, appendBlockImpl, options.getRetryPolicyFactory(), opContext);
@Override public void validateStreamWrite(StreamMd5AndLength descriptor) throws StorageException { if (this.getLength() != null && this.getLength() != -1) { if (length != descriptor.getLength()) { throw new StorageException(StorageErrorCodeStrings.INVALID_INPUT, SR.INCORRECT_STREAM_LENGTH, HttpURLConnection.HTTP_FORBIDDEN, null, null); } } } };
@Override public void setHeaders(HttpURLConnection connection, Void parentObject, OperationContext context) { connection.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, descriptor.getMd5()); }
StreamMd5AndLength descriptor = new StreamMd5AndLength(); descriptor.setLength(length); if (descriptor.getLength() > Constants.MAX_BLOCK_SIZE) this.uploadBlockInternal(blockId, descriptor.getMd5(), bufferedStreamReference, descriptor.getLength(), accessCondition, options, opContext);
@Override public void validateStreamWrite(StreamMd5AndLength descriptor) throws StorageException { if (this.getLength() != null && this.getLength() != -1) { if (length != descriptor.getLength()) { throw new StorageException(StorageErrorCodeStrings.INVALID_INPUT, SR.INCORRECT_STREAM_LENGTH, HttpURLConnection.HTTP_FORBIDDEN, null, null); } } } };
@Override public void setHeaders(HttpURLConnection connection, CloudBlob blob, OperationContext context) { BlobRequest.addMetadata(connection, blob.metadata, context); if (options.getUseTransactionalContentMD5()) { connection.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, descriptor.getMd5()); } }
options = BlobRequestOptions.populateAndApplyDefaults(options, BlobType.BLOCK_BLOB, this.blobServiceClient); StreamMd5AndLength descriptor = new StreamMd5AndLength(); descriptor.setLength(length); true /* rewindSourceStream */, options.getStoreBlobContentMD5()); if (descriptor.getMd5() != null && options.getStoreBlobContentMD5()) { this.properties.setContentMD5(descriptor.getMd5()); if (sourceStream.markSupported() && descriptor.getLength() != -1 && descriptor.getLength() < options.getSingleBlobPutThresholdInBytes() + 1) { this.uploadFullBlob(sourceStream, descriptor.getLength(), accessCondition, options, opContext);
@Override public HttpURLConnection buildRequest(ServiceClient client, Void parentObject, OperationContext context) throws Exception { this.setSendStream(sendStream); this.setLength(descriptor.getLength()); return BaseRequest.setServiceProperties( credentials.transformUri(client.getEndpoint()), options, null, context); }
@Override public void setHeaders(HttpURLConnection connection, CloudBlob blob, OperationContext context) { BlobRequest.addMetadata(connection, blob.metadata, context); if (options.getUseTransactionalContentMD5()) { connection.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, descriptor.getMd5()); } }
options.assertPolicyIfRequired(); StreamMd5AndLength descriptor = new StreamMd5AndLength(); descriptor.setLength(length); boolean skipPutBlob = !inputDataStream.markSupported() || descriptor.getLength() > options.getSingleBlobPutThresholdInBytes(); long byteCount = Utility.encryptStreamIfUnderThreshold(inputDataStream, targetStream, cipher, descriptor.getLength(), options.getSingleBlobPutThresholdInBytes() + 1 /*abandon if the operation hits this limit*/); descriptor.setLength(byteCount); if (!skipPutBlob && (descriptor.getLength() < 0 || options.getStoreBlobContentMD5())) { descriptor = Utility.analyzeStream(inputDataStream, descriptor.getLength(), options.getSingleBlobPutThresholdInBytes() + 1 /*abandon if the operation hits this limit*/, true /* rewindSourceStream */, options.getStoreBlobContentMD5()); if (descriptor.getMd5() != null && options.getStoreBlobContentMD5()) { this.properties.setContentMD5(descriptor.getMd5()); if (descriptor.getLength() == -1 || descriptor.getLength() > options.getSingleBlobPutThresholdInBytes()) this.uploadFullBlob(inputDataStream, descriptor.getLength(), accessCondition, options, opContext); || this.streamWriteSizeInBytes < Constants.MIN_LARGE_BLOCK_SIZE || options.getStoreBlobContentMD5() || descriptor.getLength() == -1;
@Override public HttpURLConnection buildRequest(ServiceClient client, Void parentObject, OperationContext context) throws Exception { this.setSendStream(sendStream); this.setLength(descriptor.getLength()); return BaseRequest.setServiceProperties( credentials.transformUri(client.getEndpoint()), options, null, context); }