Implement file upload

This commit is contained in:
2025-11-20 09:55:57 +09:00
parent 7c5c889c53
commit 5b3cb2cabd
9 changed files with 128 additions and 16 deletions

View File

@ -22,7 +22,7 @@
<RadzenAlert Visible="@hasError" AlertStyle="AlertStyle.Danger" Variant="Variant.Flat" Shade="Shade.Lighter" AllowClose="false">
@errorMessage
</RadzenAlert>
<RadzenUpload id="uploadWithDragAndDrop" @ref="upload" Url="upload-to-parse" Progress="@OnProgress" Complete="@OnCompleteAsync" ChooseText="Перетащите сюда или нажмите, чтобы выбрать файл" Auto="false" Multiple="false" Style="width: 100%;" />
<RadzenUpload id="uploadWithDragAndDrop" @ref="upload" Url="upload/parsing" Progress="@OnProgress" Complete="@OnCompleteAsync" ChooseText="Перетащите сюда или нажмите, чтобы выбрать файл" Accept=".xlsx" Auto="false" Multiple="false" Style="width: 100%;" />
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.End" Gap="0.5rem">
<RadzenButton Click="@Upload" Visible="@(state == UploadState.Idle)" Text="Отправить" />
<RadzenButton Click="@Close" Visible="@(state == UploadState.Idle)" ButtonStyle="ButtonStyle.Light" Text="Отмена" />
@ -44,6 +44,10 @@
int progress;
bool hasError;
string errorMessage;
int? fileToParseId;
[Parameter]
public required string UploaderId { get; set; }
void Upload()
{
@ -55,7 +59,7 @@
void Close()
{
DialogService.Close(true);
DialogService.Close(fileToParseId);
}
void OnProgress(UploadProgressArgs args)
@ -67,7 +71,13 @@
{
try
{
// TODO
var root = args.JsonResponse.RootElement;
var fileToParse = await FileToParseService.AddFileToParseAsync(
root.GetProperty("Path").GetString(),
root.GetProperty("FileName").GetString(),
UploaderId,
DateTime.Now);
fileToParseId = fileToParse.Id;
}
catch (Exception e)
{