/// <summary>
 /// Releases the blob resources used by the stream.
 /// </summary>
 public void Dispose()
 {
     if (this.originalStream != null)
     {
         this.originalStream.Dispose();
         this.originalStream = null;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the BlobWriteStream class for a page blob.
        /// </summary>
        /// <param name="pageBlob">Blob reference to write to.</param>
        /// <param name="pageBlobSize">Size of the page blob.</param>
        /// <param name="createNew">Use <c>true</c> if the page blob is newly created, <c>false</c> otherwise.</param>
        /// <param name="accessCondition">An <see cref="AccessCondition"/> object that represents the condition that must be met in order for the request to proceed. If <c>null</c>, no condition is used.</param>
        /// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies additional options for the request.</param>
        /// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
        /// <param name="transform">The ICryptoTransform function for the request.</param>
        internal BlobEncryptedWriteStream(CloudPageBlob pageBlob, long pageBlobSize, bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, ICryptoTransform transform)
        {
            CommonUtility.AssertNotNull("transform", transform);

            if (options.EncryptionPolicy.EncryptionMode != BlobEncryptionMode.FullBlob)
            {
                throw new InvalidOperationException(SR.InvalidEncryptionMode, null);
            }

            // Since this is done on the copy of the options object that the client lib maintains and not on the user's options object and is done after getting
            // the transform function, it should be fine. Setting this ensures that an error is not thrown when PutPage is called internally from the write method on the stream.
            options.SkipEncryptionPolicyValidation = true;

            this.transform   = transform;
            this.writeStream = new BlobWriteStream(pageBlob, pageBlobSize, createNew, accessCondition, options, operationContext)
            {
                IgnoreFlush = true
            };
            this.cryptoStream = new CryptoStream(this.writeStream, transform, CryptoStreamMode.Write);
        }
 /// <summary>
 /// Initializes a new instance of the BlobWriteStreamHelper class for an append blob.
 /// </summary>
 /// <param name="appendBlob">Blob reference to write to.</param>
 /// <param name="accessCondition">An object that represents the access conditions for the blob. If null, no condition is used.</param>
 /// <param name="options">An object that specifies additional options for the request.</param>
 internal BlobWriteStreamHelper(CloudAppendBlob appendBlob, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
 {
     this.originalStream = new BlobWriteStream(appendBlob, accessCondition, options, operationContext);
     this.originalStreamAsOutputStream = this.originalStream.AsOutputStream();
 }
 /// <summary>
 /// Initializes a new instance of the BlobWriteStreamHelper class for a page blob.
 /// </summary>
 /// <param name="pageBlob">Blob reference to write to.</param>
 /// <param name="pageBlobSize">Size of the page blob.</param>
 /// <param name="createNew">Use <c>true</c> if the page blob is newly created, <c>false</c> otherwise.</param>
 /// <param name="accessCondition">An object that represents the access conditions for the blob. If null, no condition is used.</param>
 /// <param name="options">An object that specifies additional options for the request.</param>
 internal BlobWriteStreamHelper(CloudPageBlob pageBlob, long pageBlobSize, bool createNew, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
 {
     this.originalStream = new BlobWriteStream(pageBlob, pageBlobSize, createNew, accessCondition, options, operationContext);
     this.originalStreamAsOutputStream = this.originalStream.AsOutputStream();
 }