Current Issue:
When uploading only 2 images, my request includes empty file entries for files 3-5, causing API errors.
Example of current request when adding 2 files: {
“style”: “realistic_image”,
“file1”: {
“value”: “IMTBuffer(…)”, // First image data
“options”: {
“filename”: “image1.png”,
“contentType”: “image/png”
}
},
“file2”: {
“value”: “IMTBuffer(…)”, // Second image data
“options”: {
“filename”: “image2.png”,
“contentType”: “image/png”
}
},
“file3”: {
“value”: undefined, // Empty - causing error
“options”: {
“contentType”: “image/png”
}
},
“file4”: {
“value”: undefined, // Empty - causing error
“options”: {
“contentType”: “image/png”
}
},
“file5”: {
“value”: undefined, // Empty - causing error
“options”: {
“contentType”: “image/png”
}
}
}
What I need:
When user uploads 2 files, request should only include:
- style parameter
- file1 with first image
- file2 with second image
- NO empty file3, file4, or file5 entries
What’s the correct way to structure the communication section to only include the files that are actually uploaded?