From 70ba87bc60288df9f1efaa3845d1f5577ed7d468 Mon Sep 17 00:00:00 2001 From: Ivan Pchelintsev Date: Tue, 21 May 2024 16:15:19 +0300 Subject: [PATCH] [#1] Read from stream asynchronously Signed-off-by: Ivan Pchelintsev --- src/FrostFS.SDK.ClientV2/Services/Container.cs | 1 + src/FrostFS.SDK.ClientV2/Services/Object.cs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/FrostFS.SDK.ClientV2/Services/Container.cs b/src/FrostFS.SDK.ClientV2/Services/Container.cs index 6e29a8f..fbd29a7 100644 --- a/src/FrostFS.SDK.ClientV2/Services/Container.cs +++ b/src/FrostFS.SDK.ClientV2/Services/Container.cs @@ -21,6 +21,7 @@ public partial class Client return response.Body.Container.ToModel(); } + //TODO: Return iterator public async Task ListContainersAsync() { var request = new ListRequest diff --git a/src/FrostFS.SDK.ClientV2/Services/Object.cs b/src/FrostFS.SDK.ClientV2/Services/Object.cs index 4136f28..8dbbe8a 100644 --- a/src/FrostFS.SDK.ClientV2/Services/Object.cs +++ b/src/FrostFS.SDK.ClientV2/Services/Object.cs @@ -132,7 +132,7 @@ public partial class Client using var stream = await PutObjectInit(request); var buffer = new byte[Constants.ObjectChunkSize]; - var bufferLength = payload.Read(buffer, 0, Constants.ObjectChunkSize); + var bufferLength = await payload.ReadAsync(buffer.AsMemory(0, Constants.ObjectChunkSize)); while (bufferLength > 0) { request.Body = new PutRequest.Types.Body @@ -142,7 +142,7 @@ public partial class Client request.VerifyHeader = null; request.Sign(_key); await stream.Write(request); - bufferLength = payload.Read(buffer, 0, Constants.ObjectChunkSize); + bufferLength = await payload.ReadAsync(buffer.AsMemory(0, Constants.ObjectChunkSize)); } var response = await stream.Close(); @@ -179,6 +179,7 @@ public partial class Client await _objectServiceClient.DeleteAsync(request); } + //TODO: Return iterator public async Task SearchObjectAsync(ContainerId cid, params ObjectFilter[] filters) { var request = new SearchRequest