private async Task UploadFiles(InputFileChangeEventArgs e)
        {
            var res = await UploadToFileServer.Invoke(e);

            if (res.Any())
            {
                Images.AddRange(res);
                await OnUpload.InvokeAsync(Images);
            }
        }
        private async Task UploadFile(InputFileChangeEventArgs e)
        {
            var res = await UploadToFileServer.Invoke(e);

            if (!string.IsNullOrEmpty(res))
            {
                Image = res;
                await OnUpload.InvokeAsync(Image);
            }
        }
Esempio n. 3
0
        private void Upload()
        {
            _ct = _cts.Token;
            Task.Run(async() =>
            {
                while (Uploading)
                {
                    if (_ct.IsCancellationRequested)
                    {
                        return;
                    }

                    await ReadChunk();

                    _ = InvokeAsync(() =>
                    {
                        double p           = (double)_currentByte / (double)_fileSize * 100d;
                        ProgressPercentage = (int)Math.Round(p);
                        StateHasChanged();
                    });
                }

                _ = InvokeAsync(() =>
                {
                    if (UploadComplete)
                    {
                        FileUploadEventArgs args = new FileUploadEventArgs()
                        {
                            Filename = _filename,
                            Data     = File
                        };
                        OnUpload.InvokeAsync(args);
                    }
                });
            });
        }
 private async Task OnDelete()
 {
     Images.Remove(Images[Index]);
     await OnUpload.InvokeAsync(Images);
 }