2
0
mirror of synced 2025-02-21 20:48:11 +00:00

working upload both local and cloud-9 node

This commit is contained in:
benbierens 2024-11-01 10:04:19 +01:00
parent 8af91ea74b
commit 768bfcc8eb
No known key found for this signature in database
GPG Key ID: 877D2C2E09A22F3A
2 changed files with 16 additions and 4 deletions

View File

@ -1,4 +1,5 @@
using CodexOpenApi;
using IdentityModel.Client;
using System.Net.Http;
using System.Windows;
using Utils;
@ -23,12 +24,12 @@ namespace DevconBoothImages
{
var config = new Configuration();
return new Codexes(
await GetCodex(config.CodexLocalEndpoint),
await GetCodex(config.CodexPublicEndpoint)
await GetCodexWithPort(config.CodexLocalEndpoint),
await GetCodexWithoutPort(config.CodexPublicEndpoint, config.AuthUser, config.AuthPw)
);
}
private async Task<CodexApi> GetCodex(string endpoint)
private async Task<CodexApi> GetCodexWithPort(string endpoint)
{
var splitIndex = endpoint.LastIndexOf(':');
var host = endpoint.Substring(0, splitIndex);
@ -47,6 +48,17 @@ namespace DevconBoothImages
return codex;
}
private async Task<CodexApi> GetCodexWithoutPort(string endpoint, string user, string pw)
{
var client = new HttpClient();
client.SetBasicAuthentication(user, pw);
var codex = new CodexApi(client);
codex.BaseUrl = $"{endpoint}/api/codex/v1";
await CheckCodex(codex, endpoint);
return codex;
}
private async Task CheckCodex(CodexApi codex, string endpoint)
{
try

View File

@ -3,7 +3,7 @@
public class Configuration
{
public string CodexLocalEndpoint { get; } = "http://localhost:8080";
public string CodexPublicEndpoint { get; } = "";
public string CodexPublicEndpoint { get; } = "https://api.testnet.codex.storage/storage/node-9";
public string AuthUser { get; } = "";
public string AuthPw { get; } = "";