Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
147807 | Sep 24,2019 06:33 PM UTC | Sep 26,2019 05:27 AM UTC | Blazor | 3 |
![]() |
Tags: File Manager |
[Index.razor]
//Converting a memory stream to base 64 string
string baseString = Convert.ToBase64String(stream.ToArray());
//Send the base 64 text
await Http.SendJsonAsync(HttpMethod.Post, "/api/Sample/Sample", new PostValue { value = baseString }); |
[sampleController] (server side controller)
[HttpPost("[Action]")]
public void Sample([FromBody] PostValue value)
{
//converting the base 64 string back to memory stream
MemoryStream sample = new MemoryStream(Convert.FromBase64String(value.value));
//saving the file locally in the machine from the memory stream
FileStream fs;
using (fs = new FileStream("output.pdf", FileMode.OpenOrCreate))
{
sample.CopyTo(fs);
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.