Skip to content

Commit

Permalink
#859 BlobWebClientLogic implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
zhabis committed May 1, 2023
1 parent 9a00b40 commit 3416858
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/Azos.Sky/Blob/BlobWebClientLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,24 @@ public async Task<ChangeResult> DeleteAsync(EntityId id)
return result;
}

public Task<VolatileBlobInfo> WriteBlockAsync(RGDID rgBlob, long offset, ArraySegment<byte> buffer, CancellationToken cancellationToken)
public async Task<VolatileBlobInfo> WriteBlockAsync(RGDID rgBlob, long offset, ArraySegment<byte> buffer, CancellationToken cancellationToken)
{
throw new NotImplementedException();
rgBlob.HasRequiredValue(nameof(rgBlob));
(offset >= 0).IsTrue("offset>=0");
buffer.Array.NonNull(nameof(buffer));

var uri = new UriQueryBuilder("block")
.Add("rgBlob", rgBlob)
.Add("offset", offset)
.ToString();

var response = await m_Server.Call(BlobServiceAddress,
nameof(IBlobStore),
new ShardKey(DateTime.UtcNow),
async (http, ct) => await http.Client.PostAndGetJsonMapAsync(uri, buffer).ConfigureAwait(false));

var result = response.UnwrapPayloadDoc<VolatileBlobInfo>();
return result;
}

}
Expand Down
9 changes: 9 additions & 0 deletions src/Azos/Web/WebCallExtensions.Call.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ public static async Task<TResult> CallAsync<TResult>(this HttpClient client,
};
content.Headers.ContentType = ctp;
}
else if (body is ArraySegment<byte> asegbody)//20230501 DKh #859
{
content = new ByteArrayContent(asegbody.Array, asegbody.Offset, asegbody.Count);
var ctp = new MediaTypeHeaderValue(contentType.Default(ContentType.BINARY))
{
CharSet = Encoding.UTF8.WebName
};
content.Headers.ContentType = ctp;
}
else
{
var jsonToSend = body.ToJson(options ?? JsonWritingOptions.CompactRowsAsMap);
Expand Down

0 comments on commit 3416858

Please sign in to comment.