Currently trying to upload an image and connect it to an existing entry.
The schema of the existing entry is
{
"name": "page rows",
"description": "",
"connection": "default",
"kind": "collectionType",
"collectionName": "page_rows",
"attributes": {
"row": {
"type": "json"
},
"images": {
"type": "media",
"multiple": true,
"required": false,
"allowedTypes": [
"images"
]
}
}
},
and I upload an image using
export const formatEntryUpload = (file, entryModel, entryID, entryField, entryPlugin = null) => {
const entryUpload = new FormData();
entryUpload.append('files', file);
entryUpload.append('ref', entryModel);
entryUpload.append('refId', entryID);
entryUpload.append('field', entryField);
if(entryPlugin) {
entryUpload.append('source', entryPlugin);
}
return entryUpload;
};
where I fill call the function by
formatEntryUpload ( file, "page_rows", id, "images", "users-permissions");
however when I do I get the following error.
[2021-02-07T21:01:35.334Z] error TypeError: Cannot read property 'associations' of undefined
at /srv/app/node_modules/strapi-connector-mongoose/lib/relations.js:250:43
at Array.forEach (<anonymous>)
at /srv/app/node_modules/strapi-connector-mongoose/lib/relations.js:235:20
at Array.reduce (<anonymous>)
at Function.update [as updateRelations] (/srv/app/node_modules/strapi-connector-mongoose/lib/relations.js:97:68)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Object.add (/srv/app/node_modules/strapi-plugin-upload/services/Upload.js:253:17)
at async Promise.all (index 0)
at async Object.upload (/srv/app/node_modules/strapi-plugin-upload/services/Upload.js:105:12)
at async Object.upload (/srv/app/node_modules/strapi-plugin-upload/controllers/Upload.js:82:18)
at async /srv/app/node_modules/strapi/lib/middlewares/router/utils/routerChecker.js:70:22
at async module.exports (/srv/app/node_modules/strapi-plugin-users-permissions/config/policies/permissions.js:97:3)
at async /srv/app/node_modules/strapi-utils/lib/policy.js:52:5
[2021-02-07T21:01:35.334Z] debug POST /upload (564 ms) 500
The image is successfully uploaded however it is not associated with the entry.