123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using LJProxy.Services;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.FileProviders;
- using Microsoft.Extensions.Primitives;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- namespace LJProxy.Providers
- {
- public class L1SvrFileProvider : IFileProvider
- {
- private string _contentRoot;
- private LJClientPoolService _ljClient;
- private string _token;
- IHttpContextAccessor _accessor;
- public L1SvrFileProvider(string contentRoot, LJClientPoolService ljClient,IHttpContextAccessor accessor)
- {
- _contentRoot = contentRoot;
- _ljClient = ljClient;
- _accessor = accessor;
- }
- public IDirectoryContents GetDirectoryContents(string subpath)
- {
- throw new NotImplementedException();
- }
- public IFileInfo GetFileInfo(string subpath)
- {
- string physicSubpath = subpath.Replace("/","\\");
- string directory = @$"{_contentRoot}\wwwroot";
- var fullFilepath = @$"{directory}{physicSubpath}";
- _token = _accessor.HttpContext.Request.Headers["Authorization"];
- var result = new L1SvrFileInfo(fullFilepath, physicSubpath,_ljClient.Pool,_token);
- return result;
- }
- public IChangeToken Watch(string filter)
- {
- throw new NotImplementedException();
- }
- }
- }
|