Skip to content

Instantly share code, notes, and snippets.

Created January 31, 2020 01:15
What would you like to do?
public class FileController : ControllerBase
private readonly IConfiguration _configuration;
private readonly ILogger<FileController> _logger;
public FileController(ILogger<FileController> logger, IConfiguration configuration)
_logger = logger;
_configuration = configuration;
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