public IStoredFile StoreFile(FileUploadModel fileUploadModel, Guid formId) { var fileBase = fileUploadModel.File; var filePath = FolderBuilder.BuildFolder(Folder, fileUploadModel, formId); var fileName = $"{Guid.NewGuid().ToString()}{Path.GetExtension(fileBase.FileName)}"; var file = UploadFile(fileBase, Path.Combine(filePath, fileName)); var storedFile = new StoredFile { Url = file.ToString(), OriginalFileName = fileBase.FileName, ContentType = fileBase.ContentType, ContentLength = fileBase.ContentLength, StoredFileName = fileName, StoredFilePath = filePath }; return(storedFile); }
public IStoredFile StoreFile(FileUploadModel fileUploadModel, Guid formId) { var folder = FolderBuilder.BuildFolder(Folder, fileUploadModel, formId); Directory.CreateDirectory(Path.Combine(RootStoragePath, folder)); var fileBase = fileUploadModel.File; var fileName = $"{Guid.NewGuid().ToString()}{Path.GetExtension(fileBase.FileName)}"; var path = Path.Combine(RootStoragePath, folder, fileName); fileBase.SaveAs(path); var storedFile = new StoredFile { Url = string.Format(FileDownloadUrlBase, fileName), OriginalFileName = fileBase.FileName, ContentType = fileBase.ContentType, ContentLength = fileBase.ContentLength, StoredFilePath = folder, StoredFileName = fileName }; return(storedFile); }