11using Microsoft . AspNetCore . Mvc . Rendering ;
2+ using ServiceStack . Configuration ;
23using ServiceStack . IO ;
4+ using ServiceStack . Text ;
35
46[ assembly: HostingStartup ( typeof ( MyApp . AppHost ) ) ]
57
@@ -12,6 +14,22 @@ public void Configure(IWebHostBuilder builder) => builder
1214 // Configure ASP.NET Core IOC Dependencies
1315 context . Configuration . GetSection ( nameof ( AppConfig ) ) . Bind ( AppConfig . Instance ) ;
1416 services . AddSingleton ( AppConfig . Instance ) ;
17+
18+ // Enable Managed File Uploads: https://docs.servicestack.net/locode/files-overview
19+ var fileFs = new FileSystemVirtualFiles ( context . HostingEnvironment . ContentRootPath ) ;
20+ services . AddPlugin ( new FilesUploadFeature (
21+ // User Writable, public readable
22+ new UploadLocation ( "pub" ,
23+ fileFs ,
24+ readAccessRole : RoleNames . AllowAnon ,
25+ maxFileBytes : 10 * 1024 * 1024 ,
26+ resolvePath : ctx => $ "pub/{ DateTime . UtcNow . ToUnixTime ( ) } /{ ctx . FileName } ") ,
27+ // User Writable, User Readable
28+ new UploadLocation ( "secure" ,
29+ fileFs ,
30+ maxFileBytes : 10 * 1024 * 1024 ,
31+ resolvePath : ctx => $ "/users/{ ctx . UserAuthId } /{ ctx . FileName } ")
32+ ) ) ;
1533 } ) ;
1634
1735 public override void Configure ( )
0 commit comments