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:
parent
30393c2867
commit
fc85983b43
|
|
@ -101,6 +101,9 @@ export class AdminVersionController {
|
||||||
},
|
},
|
||||||
@Req() req: any,
|
@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)
|
// Parse package to extract metadata (auto-fill when not provided)
|
||||||
const parsedInfo = await this.packageParser.parse(file.buffer, file.originalname);
|
const parsedInfo = await this.packageParser.parse(file.buffer, file.originalname);
|
||||||
|
|
||||||
|
|
@ -152,6 +155,9 @@ export class AdminVersionController {
|
||||||
@ApiConsumes('multipart/form-data')
|
@ApiConsumes('multipart/form-data')
|
||||||
@ApiOperation({ summary: 'Parse APK/IPA without saving (preview metadata)' })
|
@ApiOperation({ summary: 'Parse APK/IPA without saving (preview metadata)' })
|
||||||
async parsePackage(@UploadedFile() file: Express.Multer.File) {
|
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);
|
const info = await this.packageParser.parse(file.buffer, file.originalname);
|
||||||
return { code: 0, data: info };
|
return { code: 0, data: info };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,6 @@ const UploadModal: React.FC<{
|
||||||
const info = await apiClient.post<{
|
const info = await apiClient.post<{
|
||||||
versionCode?: number; versionName?: string; minSdkVersion?: string;
|
versionCode?: number; versionName?: string; minSdkVersion?: string;
|
||||||
}>('/api/v1/admin/versions/parse', formData, {
|
}>('/api/v1/admin/versions/parse', formData, {
|
||||||
headers: { 'Content-Type': 'multipart/form-data' },
|
|
||||||
timeout: 300000,
|
timeout: 300000,
|
||||||
});
|
});
|
||||||
console.log('[Upload] Parse result:', info);
|
console.log('[Upload] Parse result:', info);
|
||||||
|
|
@ -359,7 +358,6 @@ const UploadModal: React.FC<{
|
||||||
formData.append('isForceUpdate', String(isForceUpdate));
|
formData.append('isForceUpdate', String(isForceUpdate));
|
||||||
|
|
||||||
const result = await apiClient.post('/api/v1/admin/versions/upload', formData, {
|
const result = await apiClient.post('/api/v1/admin/versions/upload', formData, {
|
||||||
headers: { 'Content-Type': 'multipart/form-data' },
|
|
||||||
timeout: 300000,
|
timeout: 300000,
|
||||||
});
|
});
|
||||||
console.log('[Upload] Success:', result);
|
console.log('[Upload] Success:', result);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue