What API and which copy() method I can use to copy creating version if exist?
I am trying with API to copy asset from one to another DAM place and I want if there it already exist with same name etc, should create a version and copy new asset as new version.
Rohan.
Solved! Go to Solution.
Views
Replies
Total Likes
Thanks Vasim, but I asked for copy method from one to another place while copying. But came across following by createAsset method taking source Assets InputStream.
InputStream stream = asset.getRendition("original").getStream();
String mimetype= asset.getMimeType();
Asset desAsset=assetManager.createAsset(destinationFolderPath, stream, mimetype, true);
jcrSession.save();
I got the answer here is the method in com.day.cq.dam.api.AssetManager class, we created asset using createAsset(String path, InputStream is, String mimeType, boolean doSave)
Creates a new asset at the given path
. If an asset already exists at the given path
, its original rendition is updated instead of creating a new asset.
https://docs.adobe.com/docs/en/aem/6-0/develop/ref/javadoc/com/day/cq/dam/api/AssetManager.html#crea..., java.io.InputStream, java.lang.String, boolean)
Rohan.
For creating version you can use com.day.cq.dam.api.Asset api.
you can use following code
Resource assetRes = resourceResolverFactory.getResource(/content/dam/img_1);
Asset asset=assetRes.adaptTo(Asset.class);
asset.createRevision("label","comment");
once go through it https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/dam/api/Asset.html#createRevision(java.la..., java.lang.String)
Views
Replies
Total Likes
Thanks Vasim, but I asked for copy method from one to another place while copying. But came across following by createAsset method taking source Assets InputStream.
InputStream stream = asset.getRendition("original").getStream();
String mimetype= asset.getMimeType();
Asset desAsset=assetManager.createAsset(destinationFolderPath, stream, mimetype, true);
jcrSession.save();
I got the answer here is the method in com.day.cq.dam.api.AssetManager class, we created asset using createAsset(String path, InputStream is, String mimeType, boolean doSave)
Creates a new asset at the given path
. If an asset already exists at the given path
, its original rendition is updated instead of creating a new asset.
https://docs.adobe.com/docs/en/aem/6-0/develop/ref/javadoc/com/day/cq/dam/api/AssetManager.html#crea..., java.io.InputStream, java.lang.String, boolean)
Rohan.
Views
Like
Replies
Views
Like
Replies