@pawanpatilrocks I have not tried using metadata id. But if you have the resource path then:
Resource resource = resourceResolver.getResource("/a/path/to/a/file/in/the/dam");
Asset asset = resource.adaptTo(Asset.class);
String fileName = asset.getMetadataValue("dc:title");
if (fileName instanceof Object[]) {
Object[] titleArray = (Object[])
asset.getMetadata("dc:title"); fileName = (titleArray.length > 0) ? titleArray[0].toString() : ""; }
else { fileName = asset.getName(); } Property property = asset.adaptTo(Node.class).getNode(JcrConstants.JCR_CONTENT + "/renditions/original/" + JcrConstants.JCR_CONTENT).getProperty(JcrConstants.JCR_DATA); fileSize = property.getBinary().getSize(); String thumbnailPath = asset.adaptTo(Node.class).getNode(JcrConstants.JCR_CONTENT + "/renditions/" + "you/rendition/to/use").getPath();
public interface AssetMetadata
or
To get AssetMetadata, use Asset.getAssetMetadata()
Example:
Asset asset = assetManager.getAsset("/path/to/asset/document.pdf");
// get metadata
AssetMetadata assetMetadata = asset.getAssetMetadata();