From fc85983b43081bfc0236f9b674079086c4fd09bd Mon Sep 17 00:00:00 2001 From: hailin Date: Fri, 6 Mar 2026 10:56:58 -0800 Subject: [PATCH] fix(upload): remove explicit Content-Type header so browser sets multipart boundary Without boundary multer receives undefined file. Also add guards in backend parse/upload to avoid crash if file is missing. Co-Authored-By: Claude Sonnet 4.6 --- .../interface/http/controllers/admin-version.controller.ts | 6 ++++++ .../src/views/app-versions/AppVersionManagementPage.tsx | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/services/admin-service/src/interface/http/controllers/admin-version.controller.ts b/backend/services/admin-service/src/interface/http/controllers/admin-version.controller.ts index f673cc8..254ca75 100644 --- a/backend/services/admin-service/src/interface/http/controllers/admin-version.controller.ts +++ b/backend/services/admin-service/src/interface/http/controllers/admin-version.controller.ts @@ -101,6 +101,9 @@ export class AdminVersionController { }, @Req() req: any, ) { + if (!file) { + return { code: 400, message: 'No file uploaded — check Content-Type boundary' }; + } // Parse package to extract metadata (auto-fill when not provided) const parsedInfo = await this.packageParser.parse(file.buffer, file.originalname); @@ -152,6 +155,9 @@ export class AdminVersionController { @ApiConsumes('multipart/form-data') @ApiOperation({ summary: 'Parse APK/IPA without saving (preview metadata)' }) async parsePackage(@UploadedFile() file: Express.Multer.File) { + if (!file) { + return { code: 400, message: 'No file uploaded — check Content-Type boundary' }; + } const info = await this.packageParser.parse(file.buffer, file.originalname); return { code: 0, data: info }; } diff --git a/frontend/admin-web/src/views/app-versions/AppVersionManagementPage.tsx b/frontend/admin-web/src/views/app-versions/AppVersionManagementPage.tsx index 7541263..5123a57 100644 --- a/frontend/admin-web/src/views/app-versions/AppVersionManagementPage.tsx +++ b/frontend/admin-web/src/views/app-versions/AppVersionManagementPage.tsx @@ -325,7 +325,6 @@ const UploadModal: React.FC<{ const info = await apiClient.post<{ versionCode?: number; versionName?: string; minSdkVersion?: string; }>('/api/v1/admin/versions/parse', formData, { - headers: { 'Content-Type': 'multipart/form-data' }, timeout: 300000, }); console.log('[Upload] Parse result:', info); @@ -359,7 +358,6 @@ const UploadModal: React.FC<{ formData.append('isForceUpdate', String(isForceUpdate)); const result = await apiClient.post('/api/v1/admin/versions/upload', formData, { - headers: { 'Content-Type': 'multipart/form-data' }, timeout: 300000, }); console.log('[Upload] Success:', result);