public File CreateNew(IFormFile file, string fileName) { var fileExtension = Path.GetExtension(file.FileName).ToLower(); var filePathName = Guid.NewGuid().ToString(); // S3 File Save var resTuple = _awsS3Service.UploadFile(file, filePathName, fileExtension); var extensionExist = Context.Extensions.SingleOrDefault(e => e.Name == fileExtension); if (extensionExist == null) { var newExtension = new Extension { Name = fileExtension }; Context.Extensions.Add(newExtension); extensionExist = newExtension; } var newFile = new File { Name = fileName, PathName = filePathName + fileExtension, AwsRegion = resTuple.Item1, ThumbUrl = resTuple.Item2, ExtensionId = extensionExist.Id }; return(AddEf(newFile) ? newFile : default(File)); }
public override void Execute(FileDownloadedEventData data) { _awsS3Service.UploadFile(data.FileChangeData.FullPath); }