Hi there,
We're building an integration between Adobe Assets (6.5) and an accessibility provider where we'll send them the binaries and then they return, later, 3 different binaries with various accessibility files in. Getting the assets from AEM to them is trivial, uploading the assets to AEM in return via the HTTP API and then upload metadata is similarly trivial, but are there API methods for exporting Related Assets and then Creating or Updating Related Assets, i.e. this section:
I can't find anything in the API documentation about how to handle exporting or creating those relationships.
Thank you!
Paul.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @pcardno,
In general HTTP Asset API is not supporting either listing of relationships, or managing (adding, removing) relationship between the assets.
I would suggest to explore below options.
import com.adobe.granite.asset.api.Asset;
import com.adobe.granite.asset.api.AssetManager;
AssetManager assetManager = resourceResolver.adaptTo(AssetManager.class);
if (assetManager != null) {
Asset asset = assetManager.getAsset("/content/dam/we-retail-screens/usa.png");
/**
* First param represents relation type/name - possible values seources, derived, others
* Second param represents path to asset that will be related to given asset
*/
asset.addRelation("others", "/content/dam/we-retail-screens/we-retail-instore-logo.png");
resourceResolver.commit();
}
// GET
/content/dam/we-retail-screens/usa.manageReferences.png?item=/content/dam/we-retail-screens/usa.png
You should simply use manageReferences selector and item param, one request can contain multiple item parameters, e.g
/content/dam/we-retail-screens/usa.manageReferences.png?item=/content/dam/we-retail-screens/usa.png&item=/content/dam/we-retail-screens/italy.png
For POST I would suggest to experiment with network tab from dev tools in the browser, and maybe record POST request to get better idea/understanding what data/format is sent. You can expect that information about relation will be passed via JSON param that could look like this:
"{\"/content/dam/we-retail-screens/usa.png\":{\"name\":\"usa.png\",\"sources\":{},\"derived\":{\"/content/dam/we-retail-screens/italy.png\":{\"name\":\"\"}},\"others\":{\"/content/dam/we-retail-screens/we-retail-instore-logo.png\":{\"name\":\"we-retail-instore-logo.png\"}},\"relationName\":\"derived\"},\"/content/dam/we-retail-screens/italy.png\":{\"name\":\"italy.png\",\"sources\":{\"/content/dam/we-retail-screens/usa.png\":{\"name\":\"\"}},\"derived\":{},\"others\":{},\"relationName\":\"sources\"}}"
Please be aware that if you will go with approach number 2 you will also need to make sure to assure some authentication - because ManageReferencesServlet is not available publically - you have to be logged in to use it.
Saying that, I would rather recommend option 1, mainly because it will give you full control of HTTP contract of your endpoint etc (what methods, params you will use etc) and backend implementation - especially that Java Asset api gives you all you need. The other thing is that if you will use option 2, there is a chance something will change in the future in terms of ManageReferencesServlet contract and your solution will stop working.
Hi @pcardno,
In general HTTP Asset API is not supporting either listing of relationships, or managing (adding, removing) relationship between the assets.
I would suggest to explore below options.
import com.adobe.granite.asset.api.Asset;
import com.adobe.granite.asset.api.AssetManager;
AssetManager assetManager = resourceResolver.adaptTo(AssetManager.class);
if (assetManager != null) {
Asset asset = assetManager.getAsset("/content/dam/we-retail-screens/usa.png");
/**
* First param represents relation type/name - possible values seources, derived, others
* Second param represents path to asset that will be related to given asset
*/
asset.addRelation("others", "/content/dam/we-retail-screens/we-retail-instore-logo.png");
resourceResolver.commit();
}
// GET
/content/dam/we-retail-screens/usa.manageReferences.png?item=/content/dam/we-retail-screens/usa.png
You should simply use manageReferences selector and item param, one request can contain multiple item parameters, e.g
/content/dam/we-retail-screens/usa.manageReferences.png?item=/content/dam/we-retail-screens/usa.png&item=/content/dam/we-retail-screens/italy.png
For POST I would suggest to experiment with network tab from dev tools in the browser, and maybe record POST request to get better idea/understanding what data/format is sent. You can expect that information about relation will be passed via JSON param that could look like this:
"{\"/content/dam/we-retail-screens/usa.png\":{\"name\":\"usa.png\",\"sources\":{},\"derived\":{\"/content/dam/we-retail-screens/italy.png\":{\"name\":\"\"}},\"others\":{\"/content/dam/we-retail-screens/we-retail-instore-logo.png\":{\"name\":\"we-retail-instore-logo.png\"}},\"relationName\":\"derived\"},\"/content/dam/we-retail-screens/italy.png\":{\"name\":\"italy.png\",\"sources\":{\"/content/dam/we-retail-screens/usa.png\":{\"name\":\"\"}},\"derived\":{},\"others\":{},\"relationName\":\"sources\"}}"
Please be aware that if you will go with approach number 2 you will also need to make sure to assure some authentication - because ManageReferencesServlet is not available publically - you have to be logged in to use it.
Saying that, I would rather recommend option 1, mainly because it will give you full control of HTTP contract of your endpoint etc (what methods, params you will use etc) and backend implementation - especially that Java Asset api gives you all you need. The other thing is that if you will use option 2, there is a chance something will change in the future in terms of ManageReferencesServlet contract and your solution will stop working.
Thank you so much - I really appreciate the level of thought and detail that you've put into this, that's super helpful! I'm going to take a look into Option 2 as that looks like a great way of getting to this.
Thank you again!
Views
Replies
Total Likes
Hi
Is there any possible to download Related Assets?
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies