Hi All,
I am using Asset api to create asset and assigning metadata propertiese by adopting asset.
When I assign prperty to dc;title if any document has defined title on it is not able to assign my custom title.
Could you please suggest how to resolve this issue. Same thing is happening for dc:description field too. I need to override this with custom data.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Anny0505
resource.getChild(String) will take relative path. Just see the below updated code. No need of "asset.getPath() +".
Resource resource = asset.adaptTo(Resource.class);
Resource metaResource = resource.getChild(DAMConstants.JCR_CONTENT_METADATA);
ModifiableValueMap modifiableValueMap = metaResource.adaptTo(ModifiableValueMap.class);
modifiableValueMap.put("dc:title", "Title");
resource.getResourceResolver().commit();
AG
@Deleted Account_kumarkThank you for the response.
Please find the below code
To create asset in AEM :
asset = AssetImportUtils.createAsset(assetManager, targetPath, fileInputStream, mimeType);
To update asset props
Resource resource = asset.adaptTo(Resource.class);
Resource metaResource = resource.getChild(asset.getPath() + DAMConstants.JCR_CONTENT_METADATA);
ModifiableValueMap modifiableValueMap = metaResource.adaptTo(ModifiableValueMap.class);
modifiableValueMap.put("dc:title", "Title");
resource.getResourceResolver().commit();
Views
Replies
Total Likes
Hi @Anny0505
I am able update asset meta data title using below code. check whether required permission is set for the service user which you are using.
Resource metaResource = resourceResolver.getResource( "/content/dam/we-retail/en/products/apparel/gloves/Gloves.jpg/jcr:content/metadata");
ModifiableValueMap modifiableValueMap = metaResource.adaptTo(ModifiableValueMap.class);
modifiableValueMap.put("dc:title", "Title After Update");
if(resourceResolver.hasChanges()){
resourceResolver.commit();
}
Asset Before Update (with title configured) :
Asset After Update (using service resource resolver in backend) :
Hope this helps!
Thank you @Manjunath_K. Does your document has title property set?
before you upload document to DAm server please open with PDF and right click on the document CLick on Document Properties. Check if your document has properties set. if Not for me also it updating title.
If I have document propertiese set on asset file then it is not overriding.
Views
Replies
Total Likes
Hi @Anny0505
I tried the steps which you provided i.e. uploading pdf file with having title on DAM, i was able to update that pdf asset tile in backend & was not able to reproduce the issue which you are facing. try to check ModifiableValueMap in debug mode/printing in log after putting new title to it.
Views
Replies
Total Likes
Thank you @Manjunath_K. I am using servlet and using request onject. still it is not updating title.
I am getting below error com.adobe.xmp.worker.files.ncomm.XMPFilesNComm [XMPFilesProcessor.exe-4316] vcfoundation::ncomm::NCException: XMP Error 9: File could not be saved
race: 1 011330A0
2 01133128
3 011320A5
4 0113275E
5 01132572
6 0113166C
Views
Replies
Total Likes
Hi @Anny0505
resource.getChild(String) will take relative path. Just see the below updated code. No need of "asset.getPath() +".
Resource resource = asset.adaptTo(Resource.class);
Resource metaResource = resource.getChild(DAMConstants.JCR_CONTENT_METADATA);
ModifiableValueMap modifiableValueMap = metaResource.adaptTo(ModifiableValueMap.class);
modifiableValueMap.put("dc:title", "Title");
resource.getResourceResolver().commit();
AG
Views
Likes
Replies
Views
Likes
Replies