Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3643

How to include the file name and the file extension when using MemoryStream in blazor webassembly

$
0
0

Here is my code

getting the file from FileSelectFileInfo

public FileSelectFileInfo selectedFile { get; set; }

then if there is a selected file, i store it in the variable above

private async Task OnSelectHandler(FileSelectEventArgs args){    selectedFile = args.Files[0];}

this triggers an API endpoint to be executed

private async Task OnSubmit(){    try    {        if (selectedFile != null)        {            using (var memoryStream = new MemoryStream())            {                await selectedFile.Stream.CopyToAsync(memoryStream);                memoryStream.Position = 0;            }        }        else        {            Console.WriteLine("File is empty");        }    }    catch (Exception ex)    {        Console.WriteLine(ex.Message);    }}

I'm expecting to pass it to an API endpoint that`s accepting a Stream


Viewing all articles
Browse latest Browse all 3643

Trending Articles



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