From 47f5a9401f1e83efeca8b6a5cd28e1da805811f9 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期二, 18 六月 2024 17:36:23 +0800
Subject: [PATCH] 1.设置文件上传大小 2.工艺SOP查看接口 3.工单SOP查看接口
---
VueWebCoreApi/Startup.cs | 28 ++++++++++++++++++++++------
1 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/VueWebCoreApi/Startup.cs b/VueWebCoreApi/Startup.cs
index 00f51e1..863b384 100644
--- a/VueWebCoreApi/Startup.cs
+++ b/VueWebCoreApi/Startup.cs
@@ -7,9 +7,11 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Connections;
+using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Authorization;
+using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -80,7 +82,6 @@
string basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
string xmlPath = Path.Combine(basePath, "VueWebCoreApi.xml");
c.IncludeXmlComments(xmlPath, true);
-
});
#endregion
@@ -123,6 +124,19 @@
//设置Cookies
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();
+ #region 允许大文件上传
+ //允许上传大文件
+ services.Configure<IISServerOptions>(options =>
+ {
+ options.MaxRequestBodySize = 1073741824;//此处限制最大1G
+ });
+ //解决文件上传Multipart body length limit 134217728 exceeded.
+ services.Configure<FormOptions>(x =>
+ {
+ x.ValueLengthLimit = int.MaxValue;
+ x.MultipartBodyLengthLimit = 1073741824; //此处限制最大1G
+ });
+ #endregion 允许大文件上传
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime applicationLeftTime, ILoggerFactory loggerFactory)
@@ -158,13 +172,15 @@
//添加静态文件中间件
app.UseDefaultFiles();
//添加授权文件
- app.UseStaticFiles(new StaticFileOptions() {
- ContentTypeProvider = new FileExtensionContentTypeProvider() {
+ app.UseStaticFiles(new StaticFileOptions()
+ {
+ ContentTypeProvider = new FileExtensionContentTypeProvider()
+ {
Mappings = {
- [".xls"] = "application/vnd.ms-excel",
+ [".xls"] = "application/vnd.ms-excel",
[".apk"] = "application/vnd.android.package-archive"
- }
- }
+ }
+ }
});
app.UseStaticFiles();
//跨域
--
Gitblit v1.9.3