public async Task <IActionResult> ShareAsync() { var fsoIdcsv = Request.Form["fsoIdcsv"].ToString(); var user = await _userService.GetUserFromPrincipalAsync(this.User); int[] fsoIdArray = Array.ConvertAll(fsoIdcsv.Split(','), int.Parse); if (string.IsNullOrEmpty(fsoIdcsv)) { return(BadRequest()); } var fsoList = await _fsoService.GetFsoListByIdAsync(fsoIdArray); foreach (var fso in fsoList) { if (!await _fsoService.CheckOwnerAsync(fso, user)) { return(Forbid()); } } var shareKey = await _shareService.CreateShareAsync(fsoList, user); return(Ok(shareKey)); }
public async Task <IActionResult> DownloadAsync() { var fsoIdcsv = Request.Form["fsoIdcsv"].ToString(); var user = await _userService.GetUserFromPrincipalAsync(this.User); if (string.IsNullOrEmpty(fsoIdcsv)) { return(BadRequest()); } int[] fsoIdArray = Array.ConvertAll(fsoIdcsv.Split(','), int.Parse); var fsoList = await _fsoService.GetFsoListByIdAsync(fsoIdArray); var root = await _fsoService.CheckParentFso(fsoList); if (root == null || !await _fsoService.CheckOwnerAsync(root, user)) { return(Forbid()); } string contentType; if (fsoList.Count == 1 && !fsoList[0].IsFolder) { contentType = _fsoService.GetMimeType(Path.GetExtension(fsoList[0].Name)); } else { contentType = _fsoService.GetMimeType(".zip"); } var extension = Path.GetExtension(fsoList[0].Name); var stream = await _fsoService.GetFileAsync(root, fsoList, user); return(File(stream, contentType)); }