Hey @cajazzer thanks for your response.
That’s one of the things I tried. That def works if you are using the /upload API but I am trying to upload against entry creation API /api/<entry>.
In my <entry> I have 2 media types:
"images": {
"allowedTypes": [
"images"
],
"type": "media",
"multiple": true
},
"documents": {
"allowedTypes": [
"files"
],
"type": "media",
"multiple": true
}
So when I upload from the browser I do:
formData.append('data', JSON.stringify({
// fields
}))
data.images.forEach((f) => {
formData.append(`files.images`, f, f.name)
})
data.documents.forEach((f) => {
formData.append(`files.documents`, f, f.name)
})
That’s why I thought setting fileInfo.image may work. But yes setting that or just fileInfo doesn’t seem to work.
These are what I’ve tried so far:
// 1
formData.append(`fileInfo.images`, JSON.stringify([{ caption: 'test' }]))
// 2
formData.append(`fileInfo`, JSON.stringify([{ caption: 'test' }]))
// 3 (your suggestion)
formData.append('data', JSON.stringify({
// fields
fileInfo: [
{ caption: 'test' }
]
})
// 4
formData.append('data', JSON.stringify({
// fields
fileInfo: {
images: [
{ caption: 'test' }
]
}
})
// 5 - This errors - error: Invalid id, expected a string or integer, got [object Object]
formData.append('data', JSON.stringify({
// fields
images: [
{ caption: 'test' }
]
}))
I’ll have another dig into the upload plugin but I think strapi may be handling these /api/entry things differently and then passing down to upload plugin