System Information
- Strapi Version: 4
- Operating System: Mac
- Database: Postgres
- Node Version:
- NPM Version:
- Yarn Version:
I am facing this issue that my image is uploaded to media library but not showing inside strapi collection (if I am including field value inside data it is showing me this error: error: delete from “files_related_morphs” where (((“related_type” = $1 and “field” = $2 and “related_id” in ($3)))) - value “1684930024903” is out of range for type integer"
My code looks like this now
import { statSync } from "fs";
import { join } from "path";
export default {
register(/*{ strapi }*/) {},
async bootstrap({ strapi }) {
const uploadFile = async (strapi, { data, file }) => {
const { refId, ref, field } = data;
const { name, path, type } = file;
const fileStat = statSync(path);
console.log(
"strapi.plugins.upload",
strapi.plugins.upload.services.upload.upload
);
const [uploadedFile] = await strapi.plugins.upload.services.upload.upload(
{
data,
files: {
path,
name,
type,
size: fileStat.size,
},
}
);
return uploadedFile;
};
const uploadedTodoMedia = await uploadFile(strapi, {
data: {
refId: Date.now().toString(),
ref: "api::setting.setting",
// field: "logoPng", //if I am using this field it gives me this error 'error: delete from "files_related_morphs" where ((("related_type" = $1 and "field" = $2 and "related_id" in ($3)))) - value "1684930024903" is out of range for type integer
},
file: {
path: join(
__dirname,
"../../public/uploads/chassis_only_included_bf30508712.png"
),
name: "genericLogoPng.png",
type: "image/png",
},
});
console.log(uploadedTodoMedia, "uploadedTodoMedia");
strapi.entityService.create("api::setting.setting", {
data: {
name: "GenericOEM",
primaryColor: "#000000",
secondaryColor: "#ffffff",
logoPng: uploadedTodoMedia.id, // I want to show image here
},
});
},
};
Can someone please tell me what to write inside data object to have image inside my collection.
Here in logoPng?
On discord: Discord