Hi,
Currently i am trying to migrate assets and its metadata with smart crop images from one aem cloud instance to another aem cloud instance. I can able to fetch the asset and its metadata from the source aem folder. would like to know is there any api we can use to fetch the smart crops also? When i hit the /api/assets/wknd/investors/asset.jpg/renditions.json -> i am getting only the renditions not the smart crops image details.
/api/assets/wknd/investors/asset.jpg.json/jcr:content/metadata.json -> giving the metadata properties. I could see that
hasLocalCrops: true
Anyone has any idea how to retrieve the smart crop images. I am using Aio app builder in this migration process.
Thanks,
Bhavani Bharanidharan
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Below api and the function will give the smart crop of the assets in the json format.
async function fetchSmartCrop(aemUrl, accessToken, folderPath, assetName) {
console.log("Fetch Asset metadata of:", assetName);
const smartCropUrl = `${aemUrl}/content/dam/${folderPath}/${assetName}/jcr:content.3.json`;
console.log(`smart crop: ${smartCropUrl}`);
try {
const response = await fetch(smartCropUrl, {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`
}
});
if (!response.ok) {
throw new Error(`Error fetching metadata: ${response.statusText}`);
}
const smartCropProperties = await response.json();
console.log(`Smart crop: ${JSON.stringify(smartCropProperties, null, 2)}`);
return smartCropProperties;
} catch (error) {
console.log(`Error fetching asset smartcrop: ${error.message}`);
throw error;
}
}
Views
Replies
Total Likes
Hi @BhavaniBharani ,
Since you are moving the assets from one Cloud instance to another, the Assets will still be processed on the new AEM instance, since smart crop is a configuration, doesn't it make sense to have it configure it on the new instance and let it run when assets are uploaded as part of the Post Processor ?
I can imagine you would want to save resource by including the smart crops via API as well but it would make more sense to let the new system do the processing.
Regards,
Anupam Patra
Views
Replies
Total Likes
Below api and the function will give the smart crop of the assets in the json format.
async function fetchSmartCrop(aemUrl, accessToken, folderPath, assetName) {
console.log("Fetch Asset metadata of:", assetName);
const smartCropUrl = `${aemUrl}/content/dam/${folderPath}/${assetName}/jcr:content.3.json`;
console.log(`smart crop: ${smartCropUrl}`);
try {
const response = await fetch(smartCropUrl, {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`
}
});
if (!response.ok) {
throw new Error(`Error fetching metadata: ${response.statusText}`);
}
const smartCropProperties = await response.json();
console.log(`Smart crop: ${JSON.stringify(smartCropProperties, null, 2)}`);
return smartCropProperties;
} catch (error) {
console.log(`Error fetching asset smartcrop: ${error.message}`);
throw error;
}
}
Views
Replies
Total Likes
Views
Like
Replies
Views
Likes
Replies
Views
Likes
Replies