You must set headers ‘multipart/form-data’ and image source.
This code works.
const updatePicture = async (picture, axios) => {
const formData = new FormData()
formData.append('files', picture.files)
formData.append('ref', picture.ref) // optional, you need it if you want to link the image to an entry
formData.append('refId', picture.refId) // optional, you need it if you want to link the image to an entry
formData.append('field', picture.field)
formData.append('source', picture.source)
await axios.post('/upload', formData, {
headers: {
'content-type': 'multipart/form-data'
}
})
}
@davidgbell answer given by @manutepowa is right. But it’s ok if the header is not set. The issue is probably because of the source name. The source value should be the plugin name in which your entry exists. For the tables that you create source name is “content-manager”. Giving the correct source name i.e., correct plugins should work. Also, check for the correct ref and field name as well.