from what I have seen all the action happens when I press submit of the form that contains:
<ImageInput multiple source="pictures" accept="image/*">
<ImageField source="src" title="title" />
</ImageInput>
then some code like that is being run:
const addUploadCapabilities = requestHandler => (type, resource, params) => {
if ( (type === 'CREATE' || type === "UPDATE")) {
if (params.data.pictures && params.data.pictures.length) {
const pictures = params.data.pictures.filter(p => p.rawFile instanceof File)
const url = config.uploadImageEndpoint;
//the params contain the image as a fileInstance
params.data.pictures = [];
for (let picture of pictures) {
let form = new FormData();
form.append('file', picture.rawFile);
let options = APIUtils.createOptionsForImageUpload(form);
return fetchUtils.fetchJson(url, options)
.then(res => {
params.data.pictures.push({id: res.json.content[0].id});
return requestHandler(type, resource, params)
});
}
}
}
return requestHandler(type, resource, params);
};
and then the restClient code is run to save the resource of the form on either create or edit..
I am curious how to get the ids after those files are saved in the database.. and then submit the form and connect those ids to the specific ImageInputs..
Edit:
With the above code I get only an array with the first id of my pictures
Thanks!