First Commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class AttachmentsController : ControllerBase
|
||||
{
|
||||
private readonly IWebHostEnvironment _env;
|
||||
public AttachmentsController(IWebHostEnvironment env) => _env = env;
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Upload([FromForm] IFormFileCollection files, [FromForm] int jobId)
|
||||
{
|
||||
var folder = Path.Combine(_env.ContentRootPath, "Attachments", jobId.ToString());
|
||||
Directory.CreateDirectory(folder);
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
var path = Path.Combine(folder, file.FileName);
|
||||
using var stream = new FileStream(path, FileMode.Create);
|
||||
await file.CopyToAsync(stream);
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user