public async Task <IActionResult> Upload([FromForm] IFormFile file, [FromForm] string name, [FromRoute] ulong server, [FromForm] List <uint> categories) { var token = new CancellationTokenSource(TimeSpan.FromSeconds(30)).Token; var authEntry = HttpContext.GetAuthEntry(); if (authEntry is null) { return(Redirect("/login")); } var userGuilds = await userService.GetAllowedUserGuilds(authEntry); if (!userGuilds.Any(x => x.Id == server)) { return(Unauthorized()); } if (!IsValidName(name, out var cleanedName)) { return(BadRequest("Invalid quote name")); } var audio_owner = await audioProcessingService.Upload(file, server, authEntry.UserId, cleanedName, token); foreach (var categoryId in categories) { var category = await categoryRepo.GetCategory(categoryId); if (category != null && category.OwnerId == server) { await audioCategoryRepo.Create(audio_owner.Id, category.Id); } } return(RedirectToAction("Index", new { server })); }
public async Task <IActionResult> Upload(UploadFileForm uploadFileForm) { //var token = new CancellationTokenSource(TimeSpan.FromSeconds(30)).Token; var authEntry = HttpContext.GetAuthEntry(); if (authEntry is null) { return(Redirect("/login")); } await audioProcessingService.Upload(uploadFileForm.File, authEntry.UserId, authEntry.UserId, uploadFileForm.Name); return(Ok()); }