From 9d3c7ae17c1f21142cc135bb6fa15ca61670580e Mon Sep 17 00:00:00 2001 From: Matthias-VE Date: Fri, 24 May 2024 00:11:48 +0200 Subject: [PATCH 1/2] Fix breaking bug for express server --- backend/web-bff/App/util/handleMultipart.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/web-bff/App/util/handleMultipart.js b/backend/web-bff/App/util/handleMultipart.js index 783cd402..387ea8f8 100644 --- a/backend/web-bff/App/util/handleMultipart.js +++ b/backend/web-bff/App/util/handleMultipart.js @@ -10,8 +10,14 @@ function handleMultipart(req, res, next) { bb.on('file', (name, file, info) => { const {filename, encoding, mimetype} = info; + const buffers = []; file.on('data', (data) => { - form.append(name, data, {filename, contentType: mimetype}); + buffers.push(data); + }); + + file.on('end', () => { + const buffer = Buffer.concat(buffers); + form.append(name, buffer, { filename, contentType: mimetype }); }); }); From 869142866137e37b3c153b2ba6add87fcede0fa1 Mon Sep 17 00:00:00 2001 From: usserwoutV2 Date: Fri, 24 May 2024 00:36:54 +0200 Subject: [PATCH 2/2] Fixed file url --- .../src/pages/project/components/SubmissionsTable.tsx | 2 +- .../src/pages/submission/components/SubmissionCard.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/pages/project/components/SubmissionsTable.tsx b/frontend/src/pages/project/components/SubmissionsTable.tsx index ea6a8e8f..fceef563 100644 --- a/frontend/src/pages/project/components/SubmissionsTable.tsx +++ b/frontend/src/pages/project/components/SubmissionsTable.tsx @@ -121,7 +121,7 @@ const SubmissionsTable: FC<{ submissions: ProjectSubmissionsType[] | null; onCha const downloadSubmission = async (submission: ProjectSubmissionsType) => { if (!submission.submission) return console.error("No submission found"); - downloadFile(submission.submission.fileUrl, submission.group.name + ".zip"); + downloadFile(submission.submission.fileUrl.replace("/api/", "/web/api/") as ApiRoutes.SUBMISSION_FILE, submission.group.name + ".zip"); if (withArtifacts && submission.submission.artifactUrl) { downloadFile(submission.submission.artifactUrl, submission.group.name + "-artifacts.zip"); } diff --git a/frontend/src/pages/submission/components/SubmissionCard.tsx b/frontend/src/pages/submission/components/SubmissionCard.tsx index d0f4d7e0..c20a6b83 100644 --- a/frontend/src/pages/submission/components/SubmissionCard.tsx +++ b/frontend/src/pages/submission/components/SubmissionCard.tsx @@ -1,7 +1,6 @@ import { Card, theme, Button, Space } from "antd" import { useTranslation } from "react-i18next" -import { GET_Responses } from "../../../@types/requests" -import { ApiRoutes } from "../../../@types/requests" +import { GET_Responses,ApiRoutes } from "../../../@types/requests.d" import { ArrowLeftOutlined, DownloadOutlined } from "@ant-design/icons" import { useLocation, useNavigate } from "react-router-dom" import "@fontsource/jetbrains-mono" @@ -18,16 +17,17 @@ const SubmissionCard: React.FC<{ submission: SubmissionType }> = ({ submission } const location = useLocation() const index = new URLSearchParams(location.search).get("index") - + console.log(submission); const downloadFile = async (route: ApiRoutes.SUBMISSION_FILE | ApiRoutes.SUBMISSION_ARTIFACT, filename: string) => { const response = await API.GET( - route, + route.replace("/api/","/web/api/") as ApiRoutes.SUBMISSION_FILE, { config: { responseType: "blob", transformResponse: [(data) => data], }, + }, "message" )