BlockBlobWriteStream
using Azure.Storage.Blobs.Models;
using Azure.Storage.Blobs.Specialized;
using Azure.Storage.Shared;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
namespace Azure.Storage.Blobs
{
internal class BlockBlobWriteStream : StorageWriteStream
{
private readonly BlockBlobClient _blockBlobClient;
private readonly BlobRequestConditions _conditions;
private readonly List<string> _blockIds;
private readonly BlobHttpHeaders _blobHttpHeaders;
private readonly IDictionary<string, string> _metadata;
private readonly IDictionary<string, string> ;
public BlockBlobWriteStream(BlockBlobClient blockBlobClient, long bufferSize, long position, BlobRequestConditions conditions, IProgress<long> progressHandler, BlobHttpHeaders blobHttpHeaders, IDictionary<string, string> metadata, IDictionary<string, string> tags, UploadTransferValidationOptions transferValidation)
: base(position, bufferSize, progressHandler, transferValidation, null, null)
{
ValidateBufferSize(bufferSize);
_blockBlobClient = blockBlobClient;
_conditions = (conditions ?? new BlobRequestConditions());
_blockIds = new List<string>();
_blobHttpHeaders = blobHttpHeaders;
_metadata = metadata;
_tags = tags;
}
[AsyncStateMachine(typeof(<AppendInternal>d__7))]
protected override Task AppendInternal(UploadTransferValidationOptions validationOptions, bool async, CancellationToken cancellationToken)
{
<AppendInternal>d__7 stateMachine = default(<AppendInternal>d__7);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = this;
stateMachine.validationOptions = validationOptions;
stateMachine.async = async;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<CommitInternal>d__8))]
protected override Task CommitInternal(bool async, CancellationToken cancellationToken)
{
<CommitInternal>d__8 stateMachine = default(<CommitInternal>d__8);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = this;
stateMachine.async = async;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
protected override void ValidateBufferSize(long bufferSize)
{
if (bufferSize < 1)
throw new ArgumentOutOfRangeException("bufferSize", "Must be greater than 1");
if (bufferSize > 4194304000)
throw new ArgumentOutOfRangeException("bufferSize", $"""{4194304000}");
}
}
}