32 lines
666 B
C#
32 lines
666 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace BinaryDad.Notes.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class ApiController : ControllerBase
|
|
{
|
|
private readonly string filePath;
|
|
|
|
public ApiController(IConfiguration configuration)
|
|
{
|
|
filePath = configuration["ContentFilePath"];
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("save")]
|
|
public async Task<bool> Save()
|
|
{
|
|
var content = string.Empty;
|
|
|
|
using (var reader = new StreamReader(Request.Body))
|
|
{
|
|
content = await reader.ReadToEndAsync();
|
|
}
|
|
|
|
await System.IO.File.WriteAllTextAsync(filePath, content);
|
|
|
|
return true;
|
|
}
|
|
}
|