Create CSV file programmatically as DAM asset

Avatar

Avatar

smrithig4775845

Avatar

smrithig4775845

smrithig4775845

26-02-2018

Hi All,

I am working on a requirement where we need to create a CSV file from SQL database and save the file in DAM location. In order to create the CSV file in DAM location I am unsing AssetManager.createAsset("/content/dam/../..test.csv", is, "text/csv", true).

The issue that I am facing here is inorder to create asset we need an InputStream object, so I am first creating a File object and then using CSVWriter to create a CSV in another location and then converting that File object to InputStream like this ::InputStream is = new FileInputStream(csvFile);

Can someone please suggest me an approach where I can create the CSV file directly in DAM location.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

27-02-2018

Create an AEM Java service that creates a CSV file and then use the Asset Manager API or JCR NODE API to place the asset into the DAM location. Java CSV - java code samples

Answers (4)

Answers (4)

Avatar

Avatar

Hemant_arora

Avatar

Hemant_arora

Hemant_arora

27-02-2018

See this example to create CSV. Change the query according to your requirement if you want users, assets or pages to be exported in csv. https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/master/bundle/src/main/java/com/ad...

Avatar

Avatar

Hemant_arora

Avatar

Hemant_arora

Hemant_arora

26-02-2018

You can find so many examples to create csv and for uploading to dam refer to the last servlet part in this example https://helpx.adobe.com/experience-manager/using/uploading-files-aem1.html

Avatar

Avatar

smrithig4775845

Avatar

smrithig4775845

smrithig4775845

26-02-2018

Thanks for the reply. I have checked this, but this is slightly different from my requirement, I just want to create a .csv file programmatically  and place it in DAM. This file will then be pushed to another server to other uses.