Hi,
I've uploaded some documents along with some metadata properties(file uploaded using Asset Manager) in CRXDE-DAM. I need to update the meta data properties from client side and save it again in DAM. How we can perform this programmatically in CQ ? I've attached the screenshot of DAM uploaded file with meta data properties.
Solved! Go to Solution.
Views
Replies
Total Likes
A sample code:
String resourcePath = "/content/dam/geometrixx-outdoors/banners/adventure.jpg"; resourceResolver= resolverFactory.getAdministrativeResourceResolver(null); Resource res = resourceResolver.getResource(resourcePath); Resource metadataRes =res.getChild("jcr:content/metadata"); ModifiableValueMap map = metadataRes.adaptTo(ModifiableValueMap.class); //set metadata map.put("dc:samplemetadata", "sample metadata"); resourceResolver.commit(); //get metadata String metadata=map.get("dc:samplemetadata").toString();
Hope this helps.
Hi Nandhini ,
AEM is rest based. On client side update using http call.
Thanks
Views
Replies
Total Likes
Hi,
I'm new to CQ. Can you elaborate.?
Currently what I've done is after uploading the file i'll list all the uploaded file along with values stored in metadata in one page (Screen Shot Attached) and on clicking the row I'll edit some field names and update the newly edited values into CQ DAM(for the same file where we clicked), I've implemented by uploading the file again and do the modification and save it back to CRXDE dam structure(Its like uploading the file again by replacing the old file in CRXDE). My doubt is 'Is there any other possible way to do the modification without uploading the file again and save it back to DAM in CRXDE)
Thanks and Regards,
Nandhini
Views
Replies
Total Likes
Hi,
I'm new to CQ. Can you elaborate.?
Currently what I've done is after uploading the file i'll list all the uploaded file along with values stored in metadata in one page (Screen Shot Attached) and on clicking the row I'll edit some field names and update the newly edited values into CQ DAM(for the same file where we clicked), I've implemented by uploading the file again and do the modification and save it back to CRXDE dam structure(Its like uploading the file again by replacing the old file in CRXDE). My doubt is 'Is there any other possible way to do the modification without uploading the file again and save it back to DAM in CRXDE)
Thanks and Regards,
Nandhini
Views
Replies
Total Likes
Hi,
I'm new to CQ. Can you elaborate.?
Currently what I've done is after uploading the file i'll list all the uploaded file along with values stored in metadata in one page (Screen Shot Attached) and on clicking the row I'll edit some field names and update the newly edited values into CQ DAM(for the same file where we clicked), I've implemented by uploading the file again and do the modification and save it back to CRXDE dam structure(Its like uploading the file again by replacing the old file in CRXDE). My doubt is 'Is there any other possible way to do the modification without uploading the file again and save it back to DAM in CRXDE)
Thanks and Regards,
Nandhini
Views
Replies
Total Likes
Hi,
You can use script to upload file so you don't have to do manually. You can write a script which will read all file paths and upload to crx/de DAM path.
#!/bin/bash file=path.txt SOURCE="http://localhost:4502" # The user credentials on the source server (username:password) SOURCE_CRED="admin:admin" # add filters while IFS= read -r line do curl -u admin:admin -T $line http://localhost:4502/content/$line done < "$file"
In this script, it'll read paths of file defined in path.txt and push it to AEM. It's a shell script so run it on windows you can install cygwin.
Workaround : Create a folder and put all dam assets that you want to upload. Add path.txt in that folder and add asset names(don't miss out extension) in text file. Then, add shell script in folder and save it with .sh extension.
If you're using windows, download cygwin to run shell script.
Script will read all files and will update on crx/de DAM.
Thanks,
Himanshu
Views
Replies
Total Likes
Hi Himanshu,
Thanks for your time to reply to my question.
But my doubt is , how we can edit the metadata property values which is already stored in DAM. I mean I've uploaded some PDF files along with metadata values in DAM and will list all the file name along with metadata values in jsp and now i need to edit the metadata values programmatically and save it back to DAM. Code which i used to upload files and add metadata property is,
AssetManager assetManager = (AssetManager) resourceResolver.adaptTo(AssetManager.class); Asset asset = assetManager.getAssetForBinary(DamUtil.assetToBinaryPath(
assetPath)); String mimeType =this.mimeTypeService.getMimeType(fileName); asset = assetManager.createAsset(
assetPath,file1, mimeType, true); Resource metadataRes = asset.adaptTo(Resource.class).getChild("jcr:content/metadata"); ModifiableValueMap map = metadataRes.adaptTo(ModifiableValueMap.class); map.put("dc:podname", podname); map.put("dc:actualDeliveryDate", actualDeliveryDate);
Thanks ,
Nandhini
Views
Replies
Total Likes
A sample code:
String resourcePath = "/content/dam/geometrixx-outdoors/banners/adventure.jpg"; resourceResolver= resolverFactory.getAdministrativeResourceResolver(null); Resource res = resourceResolver.getResource(resourcePath); Resource metadataRes =res.getChild("jcr:content/metadata"); ModifiableValueMap map = metadataRes.adaptTo(ModifiableValueMap.class); //set metadata map.put("dc:samplemetadata", "sample metadata"); resourceResolver.commit(); //get metadata String metadata=map.get("dc:samplemetadata").toString();
Hope this helps.
Thank you Himanshu :) Your code helped me to solve the issue.
Views
Replies
Total Likes
Views
Likes
Replies