Skip to content

Commit

Permalink
Update to not use static Instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Layoric committed Jan 15, 2024
1 parent b817644 commit 2572d8c
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions TalentBlazor/Configure.AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ public void Configure(IWebHostBuilder builder) => builder
"http://localhost:5000",
"https://localhost:5001",
}, allowCredentials: true));
var wwwrootVfs = new FileSystemVirtualFiles(context.HostingEnvironment.WebRootPath);
var appDataVfs = new FileSystemVirtualFiles(context.HostingEnvironment.ContentRootPath.CombineWith("App_Data").AssertDir());
services.AddPlugin(new FilesUploadFeature(
new UploadLocation("profiles", wwwrootVfs, allowExtensions:FileExt.WebImages,
resolvePath: ctx => $"/profiles/{ctx.FileName}"),
new UploadLocation("users", wwwrootVfs, allowExtensions:FileExt.WebImages,
resolvePath: ctx => $"/profiles/users/{ctx.UserAuthId}.{ctx.FileExtension}"),
new UploadLocation("applications", appDataVfs, maxFileCount: 3, maxFileBytes: 10_000_000,
resolvePath: ctx => ctx.GetLocationPath((ctx.Dto is CreateJobApplication create
? $"jobapp/{create.JobId}/{create.ContactId}/{ctx.FileName}"
: $"app/{ctx.Dto.GetId()}") + $"/{ctx.DateSegment}/{ctx.FileName}"),
readAccessRole: RoleNames.AllowAnon, writeAccessRole: RoleNames.AllowAnon)
));
});

public AppHost() : base("TalentBlazor", typeof(MyServices).Assembly) { }
Expand All @@ -38,19 +51,7 @@ public override void Configure(Container container)
AdminAuthSecret = "secretz",
});

var wwwrootVfs = GetVirtualFileSource<FileSystemVirtualFiles>();
var appDataVfs = new FileSystemVirtualFiles(ContentRootDirectory.RealPath.CombineWith("App_Data").AssertDir());
Instance.Plugins.Add(new FilesUploadFeature(
new UploadLocation("profiles", wwwrootVfs, allowExtensions:FileExt.WebImages,
resolvePath: ctx => $"/profiles/{ctx.FileName}"),
new UploadLocation("users", wwwrootVfs, allowExtensions:FileExt.WebImages,
resolvePath: ctx => $"/profiles/users/{ctx.UserAuthId}.{ctx.FileExtension}"),
new UploadLocation("applications", appDataVfs, maxFileCount: 3, maxFileBytes: 10_000_000,
resolvePath: ctx => ctx.GetLocationPath((ctx.Dto is CreateJobApplication create
? $"jobapp/{create.JobId}/{create.ContactId}/{ctx.FileName}"
: $"app/{ctx.Dto.GetId()}") + $"/{ctx.DateSegment}/{ctx.FileName}"),
readAccessRole: RoleNames.AllowAnon, writeAccessRole: RoleNames.AllowAnon)
));

}
}

Expand Down

0 comments on commit 2572d8c

Please sign in to comment.