Gop*_*rma 4 .net-core asp.net-core-webapi
如何从 web api 核心访问文件夹中的图像?我正在做如下
https://localhost:44344/Uploaded_Documents/IMG_20190314_205925_3be1d2b3-3bac-4184-8468-995d58d5ff80.jpg
Run Code Online (Sandbox Code Playgroud)
但它给出了以下错误。
我的配置如下。
如何从 web api core 中的浏览器访问此图像?
Rya*_*yan 11
如果您想访问文件wwwroot夹外的文件,您需要按如下方式配置静态文件中间件:
app.UseStaticFiles();// For the wwwroot folder
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), "Uplodaed_Documents")),
RequestPath = "/Uplodaed_Documents"
});
//Enable directory browsing
app.UseDirectoryBrowser(new DirectoryBrowserOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), "Uplodaed_Documents")),
RequestPath = "/Uplodaed_Documents"
});
app.UseMvc();
Run Code Online (Sandbox Code Playgroud)
你可以参考asp.net core static files服务web root之外的文件
| 归档时间: |
|
| 查看次数: |
3770 次 |
| 最近记录: |