From 87ec67778bc7437f6b2bd4e5f2d4bdc1161d9520 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 25 Mar 2024 11:37:41 +0100 Subject: [PATCH] poc: upload and download streams working --- ProjectPlugins/CodexPlugin/CodexAccess.cs | 14 ++++++++++++++ ProjectPlugins/CodexPlugin/CodexNode.cs | 3 --- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ProjectPlugins/CodexPlugin/CodexAccess.cs b/ProjectPlugins/CodexPlugin/CodexAccess.cs index a305d76..f2410f7 100644 --- a/ProjectPlugins/CodexPlugin/CodexAccess.cs +++ b/ProjectPlugins/CodexPlugin/CodexAccess.cs @@ -109,6 +109,20 @@ namespace CodexPlugin private IHttp Http() { + var address = GetAddress(); + var api = new CodexOpenApi.CodexApi(new HttpClient()); + api.BaseUrl = $"{address.Host}:{address.Port}/api/codex/v1"; + + var debugInfo = Time.Wait(api.GetDebugInfoAsync()); + + using var stream = File.OpenRead("C:\\Users\\thatb\\Desktop\\Collect\\Wallpapers\\demerui_djinn_illuminatus_fullbody_full_body_view_in_the_style__86ea9491-1fe1-44ab-8577-a3636cad1b21.png"); + var cid = Time.Wait(api.UploadAsync(stream)); + + var file = Time.Wait(api.DownloadNetworkAsync(cid)); + while (file.IsPartial) Thread.Sleep(100); + using var outfile = File.OpenWrite("C:\\Users\\thatb\\Desktop\\output.png"); + file.Stream.CopyTo(outfile); + return tools.CreateHttp(GetAddress(), baseUrl: "/api/codex/v1", CheckContainerCrashed, Container.Name); } diff --git a/ProjectPlugins/CodexPlugin/CodexNode.cs b/ProjectPlugins/CodexPlugin/CodexNode.cs index de7f10f..40136dc 100644 --- a/ProjectPlugins/CodexPlugin/CodexNode.cs +++ b/ProjectPlugins/CodexPlugin/CodexNode.cs @@ -14,9 +14,6 @@ namespace CodexPlugin string GetName(); CodexDebugResponse GetDebugInfo(); CodexDebugPeerResponse GetDebugPeer(string peerId); - // These debug methods are not available in master-line Codex. Use only for custom builds. - //CodexDebugBlockExchangeResponse GetDebugBlockExchange(); - //CodexDebugRepoStoreResponse[] GetDebugRepoStore(); ContentId UploadFile(TrackedFile file); TrackedFile? DownloadContent(ContentId contentId, string fileLabel = ""); CodexLocalData[] LocalFiles();