System Information
- Strapi Version: 4.1.8
- Operating System: win 11
- Database: sqlite
- Node Version: 16.14
- NPM Version: 8.5.1
- Yarn Version: -
Image id of content type data can’t update
when request, the first generated file_id respond.
files_related_morphs table from sqlite
file_id | related_id | related_type | field | order
42 | 21 | api::event.event | image | null
43 | 21 | api::event.event | image | null
45 | 21 | api::event.event | image | null
front code
const formData = new FormData();
formData.append("files", image);
formData.append("ref", "api::event.event");
formData.append("refId", evtId);
formData.append("field", "image");
const res = await fetch(`${API_URL}/api/upload`, {
method: "POST",
headers: {
'Authorization': `Bearer ${token}`,
},
body: formData,
});
response
{
"data": {
"id": 21,
"attributes": {
"name": "test222",
"slug": "test222",
"date": "2022-04-04T15:00:00.000Z",
"time": "adasdasda",
"description": "aedwqdwdw",
"createdAt": "2022-04-20T05:30:10.701Z",
"updatedAt": "2022-04-20T05:30:10.701Z",
"image": {
"data": {
"id": 42, ◀️It is not updated to the latest
"attributes": {
"name": "f4296e9e49f41d99da5ae0aba5d88fd6.jpg",
"alternativeText": null,
"caption": null,
"width": 880,
"height": 587,
"formats": {
}
},
"ext": ".jpg",
"mime": "image/jpeg",
"size": 113.69,
"createdAt": "2022-04-20T05:35:56.821Z",
"updatedAt": "2022-04-20T05:35:56.821Z"
}
}
}
}
},
"meta": {}
}