Programmatically uploading binary files into AEM CS from external integrations

We often come across use-cases where one needs to programmatically create assets in DAM while working with AEM Assets. A typical scenario is when external systems that are integrating with AEM, need to upload/create a file to DAM. We recently tackled a similar scenario and are excited to share the design we implemented.

Creating assets in AEM CS programmatically

Most of the Java based APIs for directly creating assets are marked as deprecated [1] in AEM CS. Therefore, it is no longer recommended to upload binaries using these APIs.

The recommended way to upload binary to AEM CS is to upload them directly to cloud storage using HTTP API and the steps required for uploading are to be executed in an external application (not via AEM JVM).  This is a 3-step process [2] to successfully upload any binary file into AEM. The good news is that you don’t have to write code from scratch to execute this 3-step process, Adobe is providing open-source libraries [3] and tools to make this easier to implement.

Utilizing aem-upload module alongside Adobe application builder. We utilized the aem-upload Node.js module in App Builder to facilitate asset creation from external application to AEM CS. Below is a very high level architecture diagram of how this integration that was set up, simplified for clarity. 

Article content

 

To use aem-upload, you can create an application in Adobe app builder and include aem-upload as a module.

  • The custom application in app builder can expose an endpoint which can be used by external application. When external application wants to push the file to AEM, it can post a payload to this endpoint. Authentication mechanism is provided OOTB by Adobe app builder for enabling this securely.
  • The app builder action exposes an authenticated (recommended) endpoint which the external application will use to push the asset. Once the 3rd party application has authenticated, it can send a JSON payload response which will have the file storage information.
  • The payload can contain URL of the file(s) from an external storage (e.g. Azure blob store) and a mapping to location of where file needs to be stored in AEM (e.g. a folder path in DAM).
  • The App builder action will then process the payload, authenticate to the storage fetch and create the asset directly in the AEMCS blob store via the aem-upload module. The aem-upload module abstracts the internal asset creation process steps. It also provides options to retry, replace, versioning an asset.

Using aem-upload and Adobe app builder you can simplify your implementation to upload binary files into AEM cloud service.

 

Reference:

[1] https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/assets/admin/developer-reference-material-apis#deprecated-asset-upload-api

[2] https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/assets/admin/developer-reference-material-apis#asset-upload

[3] https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/assets/admin/developer-reference-material-apis#open-source-upload-library

[4] https://github.com/adobe/aem-upload

This is indeed a quick go to article which can be handy for any project implementation. Keep sharing 😉

Why we need app builder for this ,can’t we directly put post call to assetAPI

Like
Reply

To view or add a comment, sign in

Others also viewed

Explore content categories