BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
[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);
}
} |