public async Task SendViolationFilesToAmazonAsync(string thumbnailKey, string videoKey, Stream video, Stream thumbnail, bool isPublic = false) { await _awss3Service.UploadFile(thumbnail, thumbnailKey, isPublic); await _awss3Service.UploadFile(video, videoKey, isPublic); }
public async void UploadVideo(string path, string videoKey, string thumbnailKey) { var compressedVidePath = await _videoService.CompressVideo(path); var videoStream = File.Open(compressedVidePath, FileMode.Open); var thumbnail = _videoService.GetVideoThumbnailFromFile(compressedVidePath); await _awss3Service.UploadFile(new MemoryStream(thumbnail), thumbnailKey, false); await _awss3Service.UploadFile(videoStream, videoKey, false); }
public async Task <IActionResult> OnPostAsync(int?id) { var ClothToUpdate = await _db.Clothes.FindAsync(id); if (ClothToUpdate == null) { return(NotFound()); } if (Upload != null) { try { ClothToUpdate.PictureUri = await _awsS3Service.UploadFile(Upload); } catch (Exception e) { ModelState.AddModelError("S3 Upload", e.Message); } } if (await TryUpdateModelAsync <Clothing>( ClothToUpdate, "ClothItem", s => s.ClothName, s => s.PictureUri, s => s.IsClean, s => s.CategoryId)) { await _db.SaveChangesAsync(); return(RedirectToPage("../Dashboard")); } return(Page()); }
public async Task <IActionResult> OnPostUploadAsync(string clothingName, string category, bool isClean = false) { if (ModelState.IsValid) { string imageUri = null; if (Upload != null) { try { imageUri = await _awsS3Service.UploadFile(Upload); } catch (Exception e) { ModelState.AddModelError("S3 Upload", e.Message); } } //get UserId string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; var categoryId = category switch { "Top" => 1, "Bottom" => 2, _ => 1, }; // Create new clothing object and save it to database Clothing = new Clothing(userId, clothingName, isClean, imageUri, categoryId); db.Clothes.Add(Clothing); db.SaveChanges(); return(RedirectToPage("/Dashboard", Clothing)); } return(Page()); }