public async Task <string> UploadPhotoAsync(Guid userGuid, IFormFile file) { var uploadCommand = new UploadContent(file, _avatarAppSettings.ImageStoragePrefix); var uploadTask = Mediator.Send(uploadCommand); var updateTask = Mediator.Send(new UpdateProfilePhoto(uploadCommand.FileName, userGuid)); await Task.WhenAll(uploadTask, updateTask); return(uploadCommand.FileName); }
private void DeployFile(string fileName, UploadContent content, List <string> storageHierarchy, bool useContentPath) { string relativePath = "~/" + string.Join("/", storageHierarchy) + "/" + fileName; string path = useContentPath ? _webHelperService.ContentPath(relativePath) : _webHelperService.MapPath(relativePath); using (FileStream fs = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) { fs.Write(content.Content, 0, content.Content.Length); } }
private void DeployFiles(long tenantId, List <string> localStorageHierarchy, List <string> remoteStorageHierarchy, bool useContentPath, IUnitOfWork unitOfWork) { List <string> uploads = _storageService.List(tenantId, remoteStorageHierarchy, unitOfWork); if (uploads.Count == 0) { return; } CheckCreateFolder(localStorageHierarchy, useContentPath); foreach (string upload in uploads) { UploadContent content = _storageService.Read(tenantId, remoteStorageHierarchy, upload, unitOfWork); DeployFile(upload, content, localStorageHierarchy, useContentPath); } }
public async Task <string> UploadVideoAsync(IFormFile file, Guid userGuid) { var contestant = await GetContestantByGuid(userGuid); if (!CheckForAvailableVideoSlots(contestant)) { return(null); } var uploadCommand = new UploadContent(file, _avatarAppSettings.VideoStoragePrefix); var uploadTask = Mediator.Send(uploadCommand); var insertTask = Mediator.Send(new Insert <VideoCreation>(new VideoCreation(uploadCommand.FileName, contestant.Id, _avatarAppSettings.ShortVideoMaxLength, contestant.VideosNumber == 0))); await Task.WhenAll(uploadTask, insertTask); return(uploadCommand.FileName); }
public async Task <ActionResult> UploadContent([FromBody] UploadContent uploadContent) { await _blobService.UploadContentBlobAsync(uploadContent.Content, uploadContent.FileName); return(Ok()); }