poc: upload and download streams working

This commit is contained in:
Ben 2024-03-25 11:37:41 +01:00
parent bd5fe0cae1
commit 87ec67778b
No known key found for this signature in database
GPG Key ID: 541B9D8C9F1426A1
2 changed files with 14 additions and 3 deletions

View File

@ -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);
}

View File

@ -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();