From 523b4f8f2b641d765b871bc063daf5d270297e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=AB=A5=E5=B4=87?= <1261960504@qq.com> Date: Tue, 28 Mar 2023 15:30:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(portal):=20=E5=A2=9E=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0=E9=99=90=E5=88=B6=E5=8F=AF=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=8A=9F=E8=83=BD=20(#524)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户部署配置: 修改scow-deployment/config.py文件中的网关配置,取消对GATEWAY 的注释,修改UPLOAD_FILE_SIZE_LIMIT的值,如将默认的1G改为50M: ```py # ------- 网关配置 ------- # # GATEWAY.UPLOAD_FILE_SIZE_LIMIT:限制整个系统上传(请求)文件的大小,可接受的格式为nginx的client_max_body_size可接受的值,默认为1G # GATEWAY = { # "UPLOAD_FILE_SIZE_LIMIT": "1G", # } # ------- 网关配置 ------- # # GATEWAY.UPLOAD_FILE_SIZE_LIMIT:限制整个系统上传(请求)文件的大小,可接受的格式为nginx的client_max_body_size可接受的值,默认为1G GATEWAY = { "UPLOAD_FILE_SIZE_LIMIT": "50M", } ``` PR合并前测试步骤,用户部署无需关注: 1、与正常流程一样拉取镜像 2、修改scow-deployment 下的config.py文件,参照用户部署配置,可将UPLOAD_FILE_SIZE_LIMIT的值改为其它值,例如5M。 3、PR未被合并前,还需要修改scow-deployment 下的generate.py,增加了对UPLOAD_FILE_SIZE_LIMIT的配置,具体参考此PR对deploy/local/generate.py文件的修改,复制即可。 4、进入文件管理,点击文件上传,展示了文件上传的最大限制。尝试上传1个10M的文件,失败 ![image](https://user-images.githubusercontent.com/25954437/227121002-df50b29a-c65c-48cb-89ff-138a9c6b899a.png) --- .changeset/many-humans-work.md | 8 ++++++++ .gitignore | 1 + apps/gateway/src/env.ts | 3 ++- apps/portal-web/config.js | 4 ++++ .../src/pageComponents/filemanager/UploadModal.tsx | 4 ++++ apps/portal-web/src/utils/config.ts | 3 ++- deploy/local/config-example.py | 7 +++++++ deploy/local/generate.py | 5 +++++ deploy/vagrant/scow/scow-deployment/config.py | 8 ++++++++ docs/docs/refs/env/gateway.md | 2 +- 10 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 .changeset/many-humans-work.md diff --git a/.changeset/many-humans-work.md b/.changeset/many-humans-work.md new file mode 100644 index 0000000000..f0ba19d0b5 --- /dev/null +++ b/.changeset/many-humans-work.md @@ -0,0 +1,8 @@ +--- +"@scow/portal-web": minor +"@scow/demo-vagrant": minor +"@scow/gateway": minor +"@scow/deploy-compose": minor +--- + +上传文件、请求最大体积限制可配置 diff --git a/.gitignore b/.gitignore index 5b512b517a..5f6abbd581 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ out dist version.json .pnpm-store +.DS_Store diff --git a/apps/gateway/src/env.ts b/apps/gateway/src/env.ts index 6414f5571c..e5bd93b2ab 100644 --- a/apps/gateway/src/env.ts +++ b/apps/gateway/src/env.ts @@ -14,7 +14,8 @@ import { envConfig, str } from "@scow/lib-config"; export const config = envConfig({ RESOLVER: str({ desc: "DNS地址", default: "127.0.0.11" }), - CLIENT_MAX_BODY_SIZE: str({ desc: "请求文件大小限制", default: "1g" }), + + CLIENT_MAX_BODY_SIZE: str({ desc: "请求文件大小限制", default: "1G" }), BASE_PATH: str({ desc: "base path", default: "" }), diff --git a/apps/portal-web/config.js b/apps/portal-web/config.js index f6c1c5d3e9..e314f909bf 100644 --- a/apps/portal-web/config.js +++ b/apps/portal-web/config.js @@ -50,6 +50,8 @@ const specs = { MIS_URL: str({ desc: "如果部署了管理系统,管理系统的URL。如果和本系统域名相同,可以只写完整的路径。将会覆盖配置文件。空字符串等价于未部署管理系统", default: "" }), NOVNC_CLIENT_URL: str({ desc: "novnc客户端的URL。如果和本系统域名相同,可以只写完整路径", default: "/vnc" }), + + CLIENT_MAX_BODY_SIZE: str({ desc: "限制整个系统上传(请求)文件的大小,可接受的格式为nginx的client_max_body_size可接受的值", default: "1G" }), }; const mockEnv = process.env.NEXT_PUBLIC_USE_MOCK === "1"; @@ -143,6 +145,8 @@ const buildRuntimeConfig = async (phase, basePath) => { PASSWORD_PATTERN_MESSAGE: commonConfig.passwordPattern?.errorMessage, BASE_PATH: basePath, + + CLIENT_MAX_BODY_SIZE: config.CLIENT_MAX_BODY_SIZE, } if (!building && !testenv) { diff --git a/apps/portal-web/src/pageComponents/filemanager/UploadModal.tsx b/apps/portal-web/src/pageComponents/filemanager/UploadModal.tsx index 2099868429..6191143519 100644 --- a/apps/portal-web/src/pageComponents/filemanager/UploadModal.tsx +++ b/apps/portal-web/src/pageComponents/filemanager/UploadModal.tsx @@ -15,6 +15,7 @@ import { App, Button, Modal, Upload } from "antd"; import { join } from "path"; import { api } from "src/apis"; import { urlToUpload } from "src/pageComponents/filemanager/api"; +import { publicConfig } from "src/utils/config"; interface Props { open: boolean; @@ -44,6 +45,9 @@ export const UploadModal: React.FC = ({ open, onClose, path, reload, clus

文件将会上传到:{path}。同名文件将会被覆盖。

+

+ 单个上传文件大小最大为:{publicConfig.CLIENT_MAX_BODY_SIZE}。 +