I am trying to query a single file size, using GQL after I have uploaded my image and upload plugin has resized it according to the settings.
However, it seems the upload plugin only returns data as of type: json
and this doesn’t allow for querying.
How can I change or resolve this json type data into a GQL type, globally, so it is available to all my endpoints?
1 Like
You can query through upload_file model using id for getting the required data.
const Data = await strapi.query('file', 'upload').findOne({id : data.image});
console.log(Data.size)
Where Data have response like
{
id: 799,
name: 'download.png',
alternativeText: '',
caption: '',
width: 177,
height: 99,
formats: null,
hash: 'download_4b63425cad',
ext: '.png',
mime: 'image/png',
size: 2.18,
url: 'https://ww.abc.com/mediafiles/blogs/download_4b63425cad.png',
previewUrl: null,
provider: 'local-provider',
provider_metadata: null,