File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
src/BootstrapBlazor.Server/Components/Samples Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 11@page " /editor"
2+
23@inject SwalService SwalService
34@inject PackageVersionService VersionManager
45@inject IStringLocalizer <Editors > Localizer
6+ @inject IOptionsMonitor <WebsiteOptions > WebsiteOption
57
68<h3 >@Localizer ["EditorsTitle"]</h3 >
79
3840</DemoBlock >
3941
4042<DemoBlock Title =" @Localizer[" EditorIsEditorTitle " ]" Introduction =" @Localizer[" EditorIsEditorIntro " ]" Name =" IsEditor" >
41- <Editor IsEditor =" true" />
43+ <Editor IsEditor =" true" OnFileUpload = " OnFileUpload " />
4244</DemoBlock >
4345
4446<DemoBlock Title =" @Localizer[" EditorHeightTitle " ]" Introduction =" @Localizer[" EditorHeightIntro " ]" Name =" Height" >
Original file line number Diff line number Diff line change @@ -111,6 +111,15 @@ private async Task InsertHtmlAsync()
111111 await Editor . DoMethodAsync ( "pasteHTML" , $ "<h1>{ Localizer [ "DoMethodAsyncPasteHTML" ] } </h1>") ;
112112 }
113113
114+ private async Task < string > OnFileUpload ( EditorUploadFile uploadFile )
115+ {
116+ var url = Path . Combine ( "images" , "uploader" ,
117+ $ "{ Path . GetFileNameWithoutExtension ( uploadFile . FileName ) } -{ DateTimeOffset . Now : yyyyMMddHHmmss} { Path . GetExtension ( uploadFile . FileName ) } ") ;
118+ var fileName = Path . Combine ( WebsiteOption . CurrentValue . WebRootPath , url ) ;
119+ var ret = await uploadFile . SaveToFile ( fileName ) ;
120+ return ret ? url : "" ;
121+ }
122+
114123 private string ? _editorCode ;
115124
116125 private async Task OnGetCode ( )
You can’t perform that action at this time.
0 commit comments