42 lines
1.3 KiB
Text
42 lines
1.3 KiB
Text
@page "/"
|
|
|
|
<PageTitle>MeowStash</PageTitle>
|
|
|
|
<h1>MeowStash</h1>
|
|
<p>A meowmeow host for stashing random files~</p>
|
|
|
|
|
|
<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();
|
|
Console.WriteLine($"Fos: /tmp/uploads/{file.Name}");
|
|
if (!System.IO.Directory.Exists("/tmp/uploads"))
|
|
{
|
|
System.IO.Directory.CreateDirectory("/tmp/uploads");
|
|
}
|
|
Console.WriteLine($"fosse");
|
|
await using var fos = System.IO.File.OpenWrite($"/tmp/uploads/{file.Name}");
|
|
Console.WriteLine("Fos opened");
|
|
await file.OpenReadStream(1024 * 1024 * 10).CopyToAsync(fos);
|
|
Console.WriteLine($"File: /tmp/uploads/{file.Name} written...");
|
|
++counter;
|
|
}
|
|
|
|
_umsg = "Done!";
|
|
StateHasChanged();
|
|
}
|
|
}
|