This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FileController : ControllerBase | |
{ | |
private readonly IConfiguration _configuration; | |
private readonly ILogger<FileController> _logger; | |
public FileController(ILogger<FileController> logger, IConfiguration configuration) | |
{ | |
_logger = logger; | |
_configuration = configuration; | |
} | |
[HttpPost] | |
public async Task<IActionResult> Post(IFormFile file) | |
{ | |
var uploadStream = file.OpenReadStream(); | |
using (var fileStream = System.IO.File.Create(Path.Join(_configuration.GetValue<string>("OutputDirectory"), Guid.NewGuid().ToString()))) | |
{ | |
await uploadStream.CopyToAsync(fileStream); | |
} | |
return Ok(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment