/// <summary> /// Uploads a stream that doesn't have a known length. In this case we can't do any optimizations like creating a request before we read all of the data. /// </summary> /// <param name="source">The stream that is the source of data.</param> /// <param name="options">An object that specifies any additional options for the request.</param> /// <param name="blockSize">The block size to be used (null - no blocks).</param> /// <returns>A sequence that represents uploading the blob.</returns> /// <remarks>This is implemented by creating a BlobStream and using that to buffer data until we have sufficient amount to be sent.</remarks> private TaskSequence UploadUnknownSizeStream(Stream source, BlobRequestOptions options, long blockSize) { // Potential Improvement: is there a better uploading scheme in absense of a known length // This function is more a defensive measure; it should be rarely called, if ever. (Can seekable stream not have length? // Cannot close as this is deferred execution var target = this.OpenWrite(options); target.BlockSize = blockSize; return source.WriteToAndCloseOutput(target); }
/// <summary> /// Uploads the blob with blocks. /// </summary> /// <param name="source">The source stream.</param> /// <param name="options">An object that specifies any additional options for the request.</param> /// <param name="blockSize">The size of the block.</param> /// <returns>A <see cref="TaskSequence"/> that uploads the blob.</returns> private TaskSequence UploadBlobWithBlocks(Stream source, BlobRequestOptions options, long blockSize) { CommonUtils.AssertNotNull("modifers", options); var target = this.OpenWrite(options); target.BlockSize = blockSize; return source.WriteToAndCloseOutput(target); }