Skip to content

Commit

Permalink
Storage - add ForwardsClientCalls to FileClient.Upload (#7609)
Browse files Browse the repository at this point in the history
Fixes #7608
  • Loading branch information
tg-msft authored Sep 18, 2019
1 parent ff421ff commit 0003c3d
Show file tree
Hide file tree
Showing 4 changed files with 423 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sdk/storage/Azure.Storage.Files/src/FileClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1869,6 +1869,7 @@ private async Task<Response<StorageFileUploadInfo>> UploadRangeFromUriInternal(
/// A <see cref="StorageRequestFailedException"/> will be thrown if
/// a failure occurs.
/// </remarks>
[ForwardsClientCalls]
public virtual Response<StorageFileUploadInfo> Upload(
Stream content,
IProgress<StorageProgress> progressHandler = default,
Expand Down Expand Up @@ -1906,6 +1907,7 @@ public virtual Response<StorageFileUploadInfo> Upload(
/// A <see cref="StorageRequestFailedException"/> will be thrown if
/// a failure occurs.
/// </remarks>
[ForwardsClientCalls]
public virtual async Task<Response<StorageFileUploadInfo>> UploadAsync(
Stream content,
IProgress<StorageProgress> progressHandler = default,
Expand Down
21 changes: 21 additions & 0 deletions sdk/storage/Azure.Storage.Files/tests/FileClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,27 @@ await TestHelper.AssertExpectedExceptionAsync<StorageRequestFailedException>(
}
}

[Test]
public async Task UploadAsync_Simple()
{
const int size = 10 * Constants.KB;
var data = this.GetRandomBuffer(size);
using (this.GetNewShare(out var share))
{
var name = this.GetNewFileName();
var file = this.InstrumentClient(share.GetRootDirectoryClient().GetFileClient(name));

await file.CreateAsync(size);
using var stream = new MemoryStream(data);
await file.UploadAsync(stream);

using var bufferedContent = new MemoryStream();
var download = await file.DownloadAsync();
await download.Value.Content.CopyToAsync(bufferedContent);
TestHelper.AssertSequenceEqual(data, bufferedContent.ToArray());
}
}

[Test]
[TestCase(512)]
[TestCase(1 * Constants.KB)]
Expand Down
Loading

0 comments on commit 0003c3d

Please sign in to comment.