In this example, notifications and buttons are implemented, so it is recommended to refer to the respective documentation.
The AstrolUploadFile component provides the logic for browsing files in the explorer, copying and pasting, as well as dragging and dropping files into the defined area. It also allows for deleting uploaded files before they are saved.
@using Astrol.Component.Basic.Button
@using Astrol.Component.Basic.UploadFile
@using Astrol.Entities.Basic.Static.Notification
@using Astrol.Entities.Basic.UI
@using Astrol.JSInterop.Base
@inject AstrolJSInterop jsI
<AstrolButton OnClick="_=>ChangeStatus(true)"
Icon="astrol-upload-cloud"
Text="Upload file"
Style="AstrolStyle.Blue" />
<AstrolUploadFile Status="@_statusUpload"
SupportedExtensions="@(new List<string> {".jpg",".png",".pdf",".xlsx"})"
Save="SaveFile"
OnClose="ChangeStatus"
Title="Upload file"
TextClose="Close"
TextSave="Save"
TextFileName="File"
TextFileSize="Size"
TextBrowse="Find, copy or drag and drop your file here."
TextErrorMaximumNumberFilesAccepted="Maximum number of files exceeded."
TextErrorWrongFileExtension="Incorrect file extension."
TextErrorFileTooBig="File too large." />
@code {
private bool _statusUpload = false;
private async Task SaveFile(List<IBrowserFile> files) {
ChangeStatus(false);
await jsI.Notification($"Attaching {files.Count} file.".NotificationSucces("astrol-upload-cloud", false));
}
private void ChangeStatus(bool newStatus) {
_statusUpload = newStatus;
}
}
@using Astrol.Component.Basic.UploadFile
@using Astrol.Entities.Basic.Static.Notification
@using Astrol.Entities.Basic.Enums
@using Astrol.Entities.Basic.UI
@using Astrol.JSInterop.Base
@inject AstrolJSInterop jsI
<AstrolUploadFileEmbedded MaxFileSize="5"
TypeStorage="TypeStorage.Megabyte"
MaxNumberOfFiles="10"
MultipleFile="true"
SupportedExtensions="@(new List<string> {".jpg",".png",".pdf",".xlsx"})"
Title="Upload file"
TextClose="Close"
TextSave="Save"
TextFileName="File"
TextFileSize="Size"
TextBrowse="Find, copy or drag and drop your file here."
TextErrorMaximumNumberFilesAccepted="Maximum number of files exceeded."
TextErrorWrongFileExtension="Incorrect file extension."
TextErrorFileTooBig="File too large."
OnChange="OnChange" />
@code {
private async Task OnChange(List<IBrowserFile> files) {
await jsI.Notification($"Attaching {files.Count} file.".NotificationSucces("astrol-upload-cloud", false));
}
}