- ServerDashbord Hinzugefügt

-Ftp Seite überarbeitet mit path auswahl und zurück plus weiter button. Fehlt noch logik zum speichern vom path in global variable (: um sie zu laden evtl local zwischen speichern damit nicht jedes mal eine anfrage zum server kommt.

-Server Dashboard beispiel mod config hinzugefügt um ftp string zu lesen und schreiben. Plugin unterstützung fehlt hier noch plus plugin muss erstmal geschrieben werden das er es kann :P
This commit is contained in:
tbS
2025-08-23 16:13:08 +02:00
parent 4a7b283aa3
commit 7afbf78bb0
11 changed files with 391 additions and 56 deletions

View File

@@ -1,10 +1,11 @@
using ReactiveUI;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Reactive;
using System.Text;
using System.Threading.Tasks;
using ReactiveUI;
using Valheim_Dashboard.ViewModels;
namespace Valheim_Dashboard
@@ -123,6 +124,32 @@ namespace Valheim_Dashboard
await fileStream.CopyToAsync(requestStream);
}
public async Task UploadTextAsync(string text, string remoteFilePath)
{
var request = CreateFtpWebRequest(remoteFilePath, WebRequestMethods.Ftp.UploadFile);
// Konvertiere den String in ein Byte-Array (UTF-8)
byte[] bytes = Encoding.UTF8.GetBytes(text);
request.ContentLength = bytes.Length;
using var requestStream = await request.GetRequestStreamAsync();
await requestStream.WriteAsync(bytes, 0, bytes.Length);
}
public async Task<string> DownloadTextAsync(string remoteFilePath)
{
var request = CreateFtpWebRequest(remoteFilePath, WebRequestMethods.Ftp.DownloadFile);
using var response = (FtpWebResponse)await request.GetResponseAsync();
using var responseStream = response.GetResponseStream();
using var reader = new StreamReader(responseStream!, Encoding.UTF8);
string content = await reader.ReadToEndAsync();
return content;
}
/// <summary>
/// Löscht eine Datei vom FTP-Server (Async).
/// </summary>