Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Filestream From Blazor Client to API

$
0
0

I have a Telerik component I am using to collect files for upload to an sftp server.

<TelerikUpload @ref="files"    AutoUpload="false"    Multiple="true"    OnUpload="@(Submit)"    OnCancel="@(Cancel)"    MaxFileSize="MaxFileSize"    Enabled="@(string.IsNullOrEmpty(StatusMessage))"></TelerikUpload>

I'm using this event to process when the upload button has been clicked:

private async Task Submit(UploadEventArgs args){    foreach (var file in args.Files)    {        await provider.Upload(file.Name);    }}

Upload is then doing the following:

string downloadsPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) +"\\Downloads";string localFilePath = Path.Combine(downloadsPath, fileName);using (var fileStream = new FileStream(localFilePath, FileMode.Open, FileAccess.Read)){    await Task.Run(() => sftp.UploadFile(fileStream, fileName), cancel);}

Now this works just fine. The problem I have is in my scenario I won't have access to the users local machine so I can't get the file path like I'm doing above. I need solutions where I can open a memory stream in the front end and have it passed back to the API.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>