李昊 4 年之前
父节点
当前提交
2d4615a683
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      gx_api/GxPress/Api/GxPress.Api/Startup.cs

+ 8 - 0
gx_api/GxPress/Api/GxPress.Api/Startup.cs

@@ -1,3 +1,4 @@
+using System.IO;
 using GxPress.Api.ServiceExtensions;
 using GxPress.Common.AppOptions;
 using GxPress.Common.Middleware;
@@ -9,6 +10,7 @@ using Microsoft.AspNetCore.Http.Features;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.FileProviders;
 using Microsoft.Extensions.Hosting;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Serialization;
@@ -116,6 +118,12 @@ namespace GxPress.Api
             app.UseRouting();
             app.UseJwtAuthorization();
             app.UseStaticFiles();
+            app.UseStaticFiles(new StaticFileOptions
+            {
+                FileProvider = new PhysicalFileProvider(
+            Path.Combine(Directory.GetCurrentDirectory(), "wwwroot")),
+                RequestPath = "/MyImages"
+            });
             app.UseCors("AllowAny");
             app.UseSwashbuckle();