Not able to retrieve images from a folder.
The images in this folder do not reflect their containing folder's name in their public id as they were moved there in Dynamic folder mode, as a result when i try to fetch all the photos a that folder it results null.
CODE:
const fetchMediaFromFolder = async (folderPath) => { try { const result = await cloudinary.api.resources({ type: 'upload', prefix: folderPath, resource_type: 'image', }); return result.resources; } catch (error) { throw new Error('Error fetching media from folder: ' + error.message); }};
This results Null on fetchMediaFromFolder('Tarang "23') even though it have multiple images.
Answers
-
have you tried resources_by_asset_folder? not sure but it might work
const fetchMediaFromFolder = async (folderPath) => {
try {
const result = await cloudinary.api.resources_by_asset_folder({
asset_folder: folderPath,
resource_type: 'image',
});
return result.resources;
} catch (error) {
throw new Error('Error fetching media from folder: ' + error.message);
}
};fetchMediaFromFolder('Tarang "23"');
1 -
Hi @Harshit_2004,
I see you deleted all the folders. When looking at our logs, it seems it was the format of the text you were passing as we were raising the following error:
AppException: Query Error (at position 18) 'folder=Tarang "23 ➥➥➥'
Happy to investigate further if you recreate the folder.
Best,
Loic
0