public async Task Upload(string objectName, Stream readOnlyInput, CancellationToken cancellationToken) { if (readOnlyInput is null) { throw new ArgumentNullException(nameof(readOnlyInput)); } CheckObjectName(objectName); await Task.WhenAll( _locker.Lock(cancellationToken), _writer.Upload(objectName, readOnlyInput, cancellationToken)); }
public async Task Upload(string objectName, Stream readOnlyInput, CancellationToken cancellationToken) { if (objectName is null) { throw new ArgumentNullException(nameof(objectName)); } try { await _inner.Upload(objectName, readOnlyInput, cancellationToken); } catch (OperationCanceledException) { throw; } #pragma warning disable CA1031 // Do not catch general exception types -- it's better to continue synchronizing instead of failing completely catch #pragma warning restore CA1031 // Do not catch general exception types { } }
public async Task Upload(string objectName, Stream readOnlyInput, CancellationToken cancellationToken) { long length; try { length = readOnlyInput.Length; await _inner.Upload(objectName, readOnlyInput, cancellationToken); } catch (OperationCanceledException) { throw; } catch { _writer.Add(_prefix + "upload_errors", 1); throw; } _writer.Add(_prefix + "uploads", 1); _writer.Add(_prefix + "uploads_length", length); }