李昊 4 years ago
parent
commit
2d4615a683
1 changed files with 8 additions and 0 deletions
  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();