내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
해결됨

Correct API to create Asset in AEM programmatically as AssetManager.create is deprecated now

Avatar

Level 3

Hi All,

 

I am creating a CSV file in AEM for which I am using assetManager createAsset method but that is deprecated now.

What is the correct API to use instead?

 

https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/assets/admin/develo...

 

InputStream is = new ByteArrayInputStream(testData);
assetManager.createAsset(BASE_OUTPUT_FOLDER_PATH + "/"+ reportConfig.getReportFormBean().getReportName(), is,
"text/csv", true);

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Level 3

Hi All,

 

I think I am good with question as I am now using createOrReplaceAsset method

 

createAsset method is not well suited with new architecture and have performance issues

In AEM as a Cloud Service, assets should instead take advantage of direct binary access. A discussion of this change as well as an SDK to ease implementation of this new pattern can be found at aem-upload.

 

Below is the updated code I am using

byte[] csvData = stream.toByteArray();
InputStream is = new ByteArrayInputStream(csvData);

final ValueFactory valueFactory = session.getValueFactory();
final Binary binary = valueFactory.createBinary(is);

Asset csv = assetManager.createOrReplaceAsset(
BASE_OUTPUT_FOLDER_PATH + "/" + reportConfig.getReportFormBean().getReportName(), binary, "text/csv",
true);

Thanks,

Shehjad

원본 게시물의 솔루션 보기

3 답변 개

Avatar

Level 4

Avatar

정확한 답변 작성자:
Level 3

Hi All,

 

I think I am good with question as I am now using createOrReplaceAsset method

 

createAsset method is not well suited with new architecture and have performance issues

In AEM as a Cloud Service, assets should instead take advantage of direct binary access. A discussion of this change as well as an SDK to ease implementation of this new pattern can be found at aem-upload.

 

Below is the updated code I am using

byte[] csvData = stream.toByteArray();
InputStream is = new ByteArrayInputStream(csvData);

final ValueFactory valueFactory = session.getValueFactory();
final Binary binary = valueFactory.createBinary(is);

Asset csv = assetManager.createOrReplaceAsset(
BASE_OUTPUT_FOLDER_PATH + "/" + reportConfig.getReportFormBean().getReportName(), binary, "text/csv",
true);

Thanks,

Shehjad

Avatar

Level 1

createOrReplaceAsset is also deprecated with the latest Cloud Service version. What would be the new way to achieve this in a Java code?