MeowStash/Pages/Index.razor

36 lines
1 KiB
Text
Raw Normal View History

2023-01-03 23:39:51 +01:00
@page "/"
<PageTitle>MeowStash</PageTitle>
<h1>MeowStash</h1>
<p>A meowmeow host for stashing random files~</p>
2023-01-08 14:54:50 +01:00
<InputFile OnChange="@SendFiles" multiple /><br />
<span class="@_umsg_class">@_umsg</span>
@code {
private string _umsg = "", _umsg_class = "text-hidden";
private async Task SendFiles(InputFileChangeEventArgs e)
{
Console.WriteLine($"Files: {e.FileCount}");
var files = e.GetMultipleFiles(e.FileCount);
_umsg_class = "text-green";
int counter = 1;
foreach (var file in files)
{
_umsg = $"Uploading {counter}/{e.FileCount} files...";
StateHasChanged();
await using var fos = System.IO.File.OpenWrite($"/tmp/uploads/{file.Name}");
await file.OpenReadStream(1024 * 1024 * 10).CopyToAsync(fos);
Console.WriteLine($"File: /tmp/uploads/{file.Name} written...");
++counter;
}
_umsg = "Done!";
StateHasChanged();
}
}