Files: refactor

This commit is contained in:
Maksim Chegulov 2022-03-03 21:01:34 +03:00
parent ee027f8508
commit 99f0f702f8
5 changed files with 913 additions and 890 deletions

View File

@ -4,7 +4,7 @@
[DefaultRoute]
[ApiController]
[ControllerName("files")]
public class ApiControllerBase : ControllerBase
public abstract class ApiControllerBase : ControllerBase
{
protected readonly FilesControllerHelper<int> _filesControllerHelperInt;
protected readonly FilesControllerHelper<string> _filesControllerHelperString;

View File

@ -65,5 +65,3 @@ global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Options;
global using Newtonsoft.Json.Linq;
global using static ASC.Api.Documents.FilesController;

File diff suppressed because it is too large Load Diff

View File

@ -23,25 +23,24 @@
*
*/
namespace ASC.Files
namespace ASC.Files;
[Scope]
public class ApiProductEntryPoint : ProductEntryPoint
{
[Scope]
public class ApiProductEntryPoint : ProductEntryPoint
public override string ApiURL
{
public override string ApiURL
{
get => "api/2.0/files/info.json";
}
get => "api/2.0/files/info.json";
}
public ApiProductEntryPoint(
// FilesSpaceUsageStatManager filesSpaceUsageStatManager,
CoreBaseSettings coreBaseSettings,
AuthContext authContext,
UserManager userManager
// SubscriptionManager subscriptionManager
): base(coreBaseSettings, authContext, userManager, null)
{
public ApiProductEntryPoint(
//FilesSpaceUsageStatManager filesSpaceUsageStatManager,
CoreBaseSettings coreBaseSettings,
AuthContext authContext,
UserManager userManager
//SubscriptionManager subscriptionManager
) : base(coreBaseSettings, authContext, userManager, null)
{
}
}
}
}
}

View File

@ -1,68 +1,67 @@
namespace ASC.Files
{
public class Startup : BaseStartup
namespace ASC.Files;
public class Startup : BaseStartup
{
public override JsonConverter[] Converters { get => new JsonConverter[] { new FileEntryWrapperConverter(), new FileShareConverter() }; }
public Startup(IConfiguration configuration, IHostEnvironment hostEnvironment)
: base(configuration, hostEnvironment)
{
public override JsonConverter[] Converters { get => new JsonConverter[] { new FileEntryWrapperConverter(), new FileShareConverter() }; }
public Startup(IConfiguration configuration, IHostEnvironment hostEnvironment)
: base(configuration, hostEnvironment)
{
}
public override void ConfigureServices(IServiceCollection services)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
}
services.AddMemoryCache();
public override void ConfigureServices(IServiceCollection services)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
base.ConfigureServices(services);
services.AddMemoryCache();
DIHelper.TryAdd<FileHandlerService>();
DIHelper.TryAdd<ChunkedUploaderHandlerService>();
DIHelper.TryAdd<DocuSignHandlerService>();
DIHelper.TryAdd<ThirdPartyAppHandlerService>();
base.ConfigureServices(services);
NotifyConfigurationExtension.Register(DIHelper);
}
DIHelper.TryAdd<FileHandlerService>();
DIHelper.TryAdd<ChunkedUploaderHandlerService>();
DIHelper.TryAdd<DocuSignHandlerService>();
DIHelper.TryAdd<ThirdPartyAppHandlerService>();
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseCors(builder =>
builder
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod());
NotifyConfigurationExtension.Register(DIHelper);
}
base.Configure(app, env);
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseCors(builder =>
builder
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod());
app.MapWhen(
context => context.Request.Path.ToString().EndsWith("httphandlers/filehandler.ashx"),
appBranch =>
{
appBranch.UseFileHandler();
});
base.Configure(app, env);
app.MapWhen(
context => context.Request.Path.ToString().EndsWith("ChunkedUploader.ashx"),
appBranch =>
{
appBranch.UseChunkedUploaderHandler();
});
app.MapWhen(
context => context.Request.Path.ToString().EndsWith("httphandlers/filehandler.ashx"),
appBranch =>
{
appBranch.UseFileHandler();
});
app.MapWhen(
context => context.Request.Path.ToString().EndsWith("ThirdPartyAppHandler.ashx"),
appBranch =>
{
appBranch.UseThirdPartyAppHandler();
});
app.MapWhen(
context => context.Request.Path.ToString().EndsWith("ChunkedUploader.ashx"),
appBranch =>
{
appBranch.UseChunkedUploaderHandler();
});
app.MapWhen(
context => context.Request.Path.ToString().EndsWith("DocuSignHandler.ashx"),
appBranch =>
{
appBranch.UseDocuSignHandler();
});
}
}
app.MapWhen(
context => context.Request.Path.ToString().EndsWith("ThirdPartyAppHandler.ashx"),
appBranch =>
{
appBranch.UseThirdPartyAppHandler();
});
app.MapWhen(
context => context.Request.Path.ToString().EndsWith("DocuSignHandler.ashx"),
appBranch =>
{
appBranch.UseDocuSignHandler();
});
}
}