2021年5月1日星期六

.NET Core UseStaticFiles mapping outside directories

I have a directory c:\temp that has 2 directories inside it, \icons and \logos I would like to map this directory in my .net core app so that I can call files inside of these dirs as follow

/upload/icons/1.png -> goes to c:\temp\icons\1.png

/upload/logos/1.png -> goes to c:\temp\logos\1.png

Is this possible with UseStaticFiles as I have below? I couldnt get it to work properly.

 app.UseStaticFiles(new StaticFileOptions              {                  FileProvider = new PhysicalFileProvider(@"c:\temp"),                  RequestPath = "/upload"              });  

I can map a single dir but not sure how to map a dir with sub dirs.

if possible, i can even get rid of upload from my paths too but just trying to separate this folder from rest of the app

https://stackoverflow.com/questions/67352402/net-core-usestaticfiles-mapping-outside-directories May 02, 2021 at 10:06AM

没有评论:

发表评论