I am encountering a similar issue with the following code snippet:
const [afields, afiles] = await form.parse(req);
The issue arises because the field name below "afiles" keeps changing, it could be "files", "image", "upload", and so on, which is puzzling to me...
To tackle this problem, I decided to iterate through the "afiles" object:
const uploadedFiles = [];
const afilesValues = Object.values(afiles);
const nbAfilesValues = afilesValues.length;
for( let i=0; i<nbAfilesValues; i++){
const value1 = afilesValues[i];
if (typeof value1 == 'object' && value1.constructor.name == 'PersistentFile'){
uploadedFiles.push(value1);
continue;
}
if (typeof value1 == 'object' && value1.constructor.name == 'Array'){
const nb2 = value1.length;
for(let i2=0; i2<nb2; i2++){
const value2 = value1[i2];
if (typeof value2 == 'object' && value2.constructor.name == 'PersistentFile'){
uploadedFiles.push(value2);
continue;
}
}
continue;
}
}
This way, all the uploaded files will be stored in the "uploadedFiles" array...