Update
All checks were successful
Build & Deploy PLDpro.Web Test to 192.168.1.100 / build-and-deploy (push) Successful in 1m13s
All checks were successful
Build & Deploy PLDpro.Web Test to 192.168.1.100 / build-and-deploy (push) Successful in 1m13s
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
<MudStack Row="true" Spacing="2">
|
||||
<MudText Typo="Typo.h6">Objekte in '@selectedBucket'</MudText>
|
||||
<MudSpacer />
|
||||
<MudTextField @bind-Value="uploadPath" Placeholder="Pfad (optional, z.B. docs/2026)" Variant="Variant.Outlined" />
|
||||
<InputFile OnChange="OnFilesSelected" />
|
||||
</MudStack>
|
||||
|
||||
@@ -54,11 +55,24 @@
|
||||
<MudTh>Key</MudTh>
|
||||
<MudTh>Größe</MudTh>
|
||||
<MudTh>Geändert</MudTh>
|
||||
<MudTh></MudTh>
|
||||
<MudTh></MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Key">@context.Key</MudTd>
|
||||
<MudTd DataLabel="Größe">@context.Size</MudTd>
|
||||
<MudTd DataLabel="Geändert">@context.LastModified</MudTd>
|
||||
<MudTd>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Primary" Href="@GetDownloadUrl(context.Key)" Target="_blank" StartIcon="@Icons.Material.Filled.Download">Download</MudButton>
|
||||
</MudTd>
|
||||
<MudTd>
|
||||
@* Name = letzter Segmentteil des Keys *@
|
||||
@{
|
||||
var fileName = context.Key.Split('/', StringSplitOptions.RemoveEmptyEntries).LastOrDefault() ?? context.Key;
|
||||
var encodedName = Uri.EscapeDataString(fileName);
|
||||
}
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Primary" Href="@($"/api/storage/buckets/{selectedBucket}/files/{encodedName}/download")" Target="_blank" StartIcon="@Icons.Material.Filled.Download">Download by Name</MudButton>
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
</MudPaper>
|
||||
@@ -72,6 +86,7 @@
|
||||
private List<ObjectVm>? objects;
|
||||
private string? selectedBucket;
|
||||
private string newBucketName = "";
|
||||
private string? uploadPath; // optionaler Pfad
|
||||
private const long StreamLimit = 512L * 1024 * 1024; // 512 MB (Program.cs erhöht Multipart-Limit)
|
||||
|
||||
private HttpClient? Http;
|
||||
@@ -83,7 +98,7 @@
|
||||
return LoadBuckets();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private async Task LoadBuckets()
|
||||
{
|
||||
@@ -116,10 +131,22 @@
|
||||
using var content = new MultipartFormDataContent();
|
||||
content.Add(new StreamContent(stream), "file", file.Name);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(uploadPath))
|
||||
content.Add(new StringContent(uploadPath!), "path");
|
||||
|
||||
var resp = await Http.PostAsync($"/api/storage/buckets/{selectedBucket}/upload", content);
|
||||
resp.EnsureSuccessStatusCode();
|
||||
}
|
||||
// Refresh list
|
||||
objects = await Http.GetFromJsonAsync<List<ObjectVm>>($"/api/storage/buckets/{selectedBucket}/objects") ?? new();
|
||||
|
||||
}
|
||||
private string GetDownloadUrl(string key)
|
||||
{
|
||||
// URL-encode für sichere Übergabe in Catch-all Route
|
||||
var encodedKey = Uri.EscapeDataString(key);
|
||||
return $"/api/storage/buckets/{selectedBucket}/download/{encodedKey}";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user