I would like to know if you can help identify the issue related to uploading an image to the thumb field belonging to the content-type Directory.
The image image does not render once it is in the strapi panel, it only shows the name.
const getFileSize = (filePath) => {
return statSync(filePath)["size"]; // statSync from `fs-extra` library
};
strapi.service("api::directory.directory").create({
data: {},
files: {
thumb: {
path: `${imagesDir}/Crab-1-1-scaled.jpg`,
name: "Crab-1-1-scaled.jpeg",
type: mime.lookup(`${imagesDir}/Crab-1-1-scaled.jpg`), // mime from `mime-types` library
size: getFileSize(`${imagesDir}/Crab-1-1-scaled.jpg`),
},
},
});
size is always zero
{
files: {
thumb: {
path: 'src/scripts/Directory/images/Crab-1-1-scaled.jpg',
name: 'Crab-1-1-scaled.jpeg',
type: 'image/jpeg',
size: 0
}
}
}
When uploading the data the image is not rendered, it only shows the name of the image.