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 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-06 10:56:58 -08:00
parent 30393c2867
commit fc85983b43
2 changed files with 6 additions and 2 deletions

View File

@ -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 };
}

View File

@ -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);