|
15 | 15 | using Volo.Abp.AspNetCore.ExceptionHandling; |
16 | 16 | using Volo.Abp.AspNetCore.Security; |
17 | 17 | using Volo.Abp.AspNetCore.Security.Claims; |
| 18 | +using Volo.Abp.AspNetCore.StaticFiles; |
18 | 19 | using Volo.Abp.AspNetCore.Tracing; |
19 | 20 | using Volo.Abp.AspNetCore.Uow; |
20 | 21 | using Volo.Abp.AspNetCore.VirtualFileSystem; |
@@ -126,6 +127,38 @@ public static IApplicationBuilder UseDynamicClaims(this IApplicationBuilder app) |
126 | 127 | return app.UseMiddleware<AbpDynamicClaimsMiddleware>(); |
127 | 128 | } |
128 | 129 |
|
| 130 | + /// <summary> |
| 131 | + /// Configures the application to serve static files that match the specified filename patterns with the WebRootFileProvider of the application. |
| 132 | + /// </summary> |
| 133 | + /// <param name="app">The <see cref="IApplicationBuilder"/> used to configure the application pipeline.</param> |
| 134 | + /// <param name="includeFileNamePatterns">The file name patterns to include when serving static files (e.g., "appsettings*.json"). |
| 135 | + /// Supports glob patterns. See <see href="https://learn.microsoft.com/en-us/dotnet/core/extensions/file-globbing">Glob patterns documentation</see>. |
| 136 | + /// </param> |
| 137 | + /// <returns>The <see cref="IApplicationBuilder"/> instance.</returns> |
| 138 | + public static IApplicationBuilder UseStaticFilesForPatterns(this IApplicationBuilder app, params string[] includeFileNamePatterns) |
| 139 | + { |
| 140 | + return UseStaticFilesForPatterns(app, includeFileNamePatterns, app.ApplicationServices.GetRequiredService<IWebHostEnvironment>().WebRootFileProvider); |
| 141 | + } |
| 142 | + |
| 143 | + /// <summary> |
| 144 | + /// Configures the application to serve static files that match the specified filename patterns with the specified file provider. |
| 145 | + /// </summary> |
| 146 | + /// <param name="app">The <see cref="IApplicationBuilder"/> used to configure the application pipeline.</param> |
| 147 | + /// <param name="includeFileNamePatterns">The file name patterns to include when serving static files (e.g., "appsettings*.json"). |
| 148 | + /// Supports glob patterns. See <see href="https://learn.microsoft.com/en-us/dotnet/core/extensions/file-globbing">Glob patterns documentation</see>. |
| 149 | + /// </param> |
| 150 | + /// <param name="fileProvider">The <see cref="IFileProvider"/> </param> |
| 151 | + /// <returns>The <see cref="IApplicationBuilder"/> instance.</returns> |
| 152 | + public static IApplicationBuilder UseStaticFilesForPatterns(this IApplicationBuilder app, string[] includeFileNamePatterns, IFileProvider fileProvider) |
| 153 | + { |
| 154 | + app.UseStaticFiles(new StaticFileOptions |
| 155 | + { |
| 156 | + FileProvider = new AbpStaticFileProvider(includeFileNamePatterns, fileProvider) |
| 157 | + }); |
| 158 | + |
| 159 | + return app; |
| 160 | + } |
| 161 | + |
129 | 162 | /// <summary> |
130 | 163 | /// MapAbpStaticAssets is used to serve the files from the abp virtual file system embedded resources(js/css) and call the MapStaticAssets. |
131 | 164 | /// </summary> |
|
0 commit comments