You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

33 lines
795 B

using Microsoft.AspNetCore.Http;
using System.Net;
using System.Threading.Tasks;
namespace Wood.Admin.WebApi.Middleware
{
public class FileBridgeMiddleware
{
private readonly RequestDelegate _next;
public FileBridgeMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext context)
{
if (context.Request.Path.ToString().Contains("fromBucket/xxx(仓储名字)"))
{
//拦截到仓储文件的路径 读取文件返回
byte[] filebytes = new byte[0];
context.Response.StatusCode = (int)HttpStatusCode.OK;
await context.Response.Body.WriteAsync(filebytes);
await context.Response.Body.FlushAsync();
}
else
{
// Call the next delegate/middleware in the pipeline.
await _next(context);
}
}
}
}