/// <inheritdoc /> protected override Task <PutResult> PutStreamCoreAsync( OperationContext operationContext, ContentHash contentHash, Stream stream, UrgencyHint urgencyHint, Counter retryCounter) { // We need a seekable stream, that can give its length. If the input stream is seekable, we can use it directly. // Otherwise, we need to create a temp file for this purpose. Stream putStream; long position; Stream disposableStream; if (stream.CanSeek) { putStream = stream; position = stream.Position; disposableStream = null; } else { putStream = TempFileStreamFactory.Create(operationContext, stream); position = 0; disposableStream = putStream; } using (disposableStream) { return(PerformRetries( operationContext, () => RpcClient.PutStreamAsync(operationContext, contentHash, stream), retryCounter: retryCounter)); } }
/// <inheritdoc /> protected override async Task <PutResult> PutStreamCoreAsync( OperationContext operationContext, HashType hashType, Stream stream, UrgencyHint urgencyHint, Counter retryCounter) { // We need a seekable stream, that can give its length. If the input stream is seekable, we can use it directly. // Otherwise, we need to create a temp file for this purpose. var putStream = stream; Stream disposableStream = null; if (!stream.CanSeek) { putStream = TempFileStreamFactory.Create(operationContext, stream); disposableStream = putStream; } using (disposableStream) { return(await PerformRetries( operationContext, () => RpcClient.PutStreamAsync(operationContext, hashType, putStream), retryCounter : retryCounter)); } }