Last active
September 16, 2018 13:47
-
-
Save JordiCorbilla/f017c2af4cb5a0a56523a80b9a27b9c1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
[HttpPost] | |
[RequestSizeLimit(300_000_000)] | |
[Authorize(Policy = "Administrator")] | |
public async Task<IActionResult> UploadFiles(List<IFormFile> files) | |
{ | |
if (files == null || files.Count == 0) | |
return Content("files not selected"); | |
foreach (var file in files) | |
{ | |
string todayDate = DateTime.UtcNow.ToString("yyyyMMdd"); | |
var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", todayDate, file.GetFilename()); | |
Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", todayDate)); | |
using (var stream = new FileStream(path, FileMode.Create)) | |
{ | |
await file.CopyToAsync(stream); | |
} | |
await ProcessImage(path); | |
await ProcessVideo(path); | |
} | |
return RedirectToAction("Files", new { date = DateTime.UtcNow.ToString("yyyyMMdd") }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment