I am unable to download the custom assets from AEM assets console but I am able to download the same assets from damadmin.
Not sure if I am missing any configuration.
We are uploading bulk assets into AEM from some other tool.
I have observed that I was using below asset manager api to create assets.
com.adobe.granite.asset.api.Asset asset = assetMgr.createAsset(absTargetPath);
But, the assets were uploaded with 0B size and that might be the reason why I was not able to download them in AEM asset console and also, they are not accessible directly on browser.
So, now I have used "com.day.cq.dam.api.AssetManager" api
com.day.cq.dam.api.Asset asset = assetMgr.createAsset(absTargetPath, is, mimeType, true);
Now, the assets are correctly uploaded with correct size and are now able to download as well.
I am not sure why granite Asset Manager api is not uploading assets properly but the reason I have used granite api is- I am doing the asset relation through code and I can only able to do that by using granite api, I am not sure if dam api has any option for creating asset relation.
AEM version : AEM 6.4
The granite Api, doesn't have method to read assets from filesystem.
It has only one parameter which is repo path where Asset would be created.
It is missing InputStream param.
AssetManager assetManager = resolver.adaptTo(AssetManager.class);
Asset newAsset = assetManager.createAsset("/path/to/asset/document.pdf");
For creating Asset, you can use com.day.cq.dam.api.AssetManager
Yes, the granite Api doesn't have method to read assets from fielsystem. So I have used com.day.cq.dam.api.AssetManager for creating assets.
Also, I have used granite api for asset relate/un-relate because com.day.cq.dam.api.AssetManager doesn't have method for asset relation.
Please let me know if this approach is fine, where we can use both api's (one for creating assets from filesystem and second for creating asset relation).
Currently, this solution is working fine for me.
Yes, it's fine to use CQ API instead Granite API.
for example Granite Workflow API doesn't have method to get session from workflow session but CQ API has, so we do use API according to the requirement.