username@email.com
2024-12-26 90858c80d9921b555119f41060c1f883f6e6ffc5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using Autofac;
using Autofac.Extensions.DependencyInjection;
using DocumentFile.Service;
using Microsoft.AspNetCore.Http.Features;
 
var builder = WebApplication.CreateBuilder(args);
 
// Add services to the container.
 
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
 
//builder.WebHost.UseKestrel(options =>
//{
//ÅäÖÃÁËÕâ¸öIISÉϲ»ÄÜÔËÐÐ
//    //options.Limits.MaxRequestLineSize = int.MaxValue;//HTTP ÇëÇóÐеÄ×î´óÔÊÐí´óС¡£ Ä¬ÈÏΪ 8kb
//    //options.Limits.MaxRequestBufferSize = int.MaxValue;//ÇëÇ󻺳åÇøµÄ×î´ó´óС¡£ Ä¬ÈÏΪ 1M
//    //ÈκÎÇëÇóÕýÎĵÄ×î´óÔÊÐí´óС£¨ÒÔ×Ö½ÚΪµ¥Î»£©,ĬÈÏ 30,000,000 ×Ö½Ú£¬´óԼΪ 28.6MB
//    options.Limits.MaxRequestBodySize = 300 * 1024 * 1024; //ÏÞÖÆÇëÇ󳤶È
//});
builder.Services.Configure<FormOptions>(options =>
{
    //ĬÈÏÉÏ´«´óСÏÞÖÆ
    options.MultipartBodyLengthLimit = 300 * 1024 * 1024;
    options.ValueLengthLimit = 300 * 1024 * 1024;
});
 
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
builder.Host.ConfigureContainer<ContainerBuilder>(builder =>
{
    //×¢²áioc
    builder.RegisterType<UploadService>().As<IUploadService>();
});
 
var app = builder.Build();
 
// Configure the HTTP request pipeline.
app.UseSwagger();
app.UseSwaggerUI(c =>
{
    c.SwaggerEndpoint("/swagger/v1/swagger.json", "V1 Docs");
    c.RoutePrefix = string.Empty;
    c.DocExpansion(Swashbuckle.AspNetCore.SwaggerUI.DocExpansion.None);
    c.DefaultModelsExpandDepth(-1);
});
 
//app.UseHttpsRedirection();
 
app.UseAuthorization();
 
app.MapControllers();
 
app.Run();