Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Best way to save, get the files in AEM application.

Avatar

Level 8

Hello all,

 

Scenario: If I want to create a feature in AEM application, which has: End user can upload pdf/docs/image file. Later, user can download the file. How can I implement such feature in AEM? 

1: Use of MongoDB to save the file?

2: DAM folder

3:  If application is hosted in AWS env. (AEM application is not using AEM as cloud service), then to rely on some AWS features to store, retrieve the files?

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Mahesh_Gunaje 

 

Below are some steps that I can think of. Please do a technical feasibility check for the below steps

 

  1. Set up a file upload component: Create a component in AEM that includes a file upload input field. This component will be used to render the file upload form on your live site. You can use HTML and AEM's component development features to create the form.

  2. Configure a DAM (Digital Asset Manager) folder for file storage: Set up a specific folder in AEM's DAM to store the uploaded files. Ensure that appropriate permissions are set for end users to upload and delete files in this folder.

  3. Handle file uploads in AEM: Implement a server-side script or servlet in AEM that handles the file upload process. This script will receive the uploaded file, validate it if necessary, and store it in the designated DAM folder. You can use AEM's API (e.g., AssetManager API) to manage the file upload process.

  4. Render uploaded files on the live site: Create a component or template that retrieves the uploaded files from the DAM folder and displays them on your live site. This component can use AEM's API (e.g., AssetManager API) to fetch the files from the DAM folder and render them as desired (e.g., as a list or gallery).

  5. Implement file deletion functionality: Add a feature to allow end users to delete files. This can be done by adding a delete button or checkbox for each uploaded file on the live site. When the user selects a file for deletion, you can implement a server-side script or servlet that handles the file deletion from the DAM folder using AEM's API.

  6. Apply appropriate security measures: Ensure that only authorized users have permissions to upload and delete files. Implement authentication and authorization mechanisms in AEM to control access to these features.

View solution in original post

7 Replies

Avatar

Community Advisor

@Mahesh_Gunaje Can you please elaborate the ask? is it within AEM ? or by end user of your website?

Did you check UGC? please check below link. If not, storing files back from website/webportal to AEM is not safe, instead let them goto an curated system.

https://business.adobe.com/au/products/experience-manager/assets/ugc-management.html

Avatar

Level 8

I think my question is misunderstood. I am aware of AEM author can upload, delete assets from DAM. 

But my task is to create a feature in my AEM application, where end user can upload files. user can delete uploaded files. etc in live(domain) site.

Avatar

Correct answer by
Community Advisor

Hi @Mahesh_Gunaje 

 

Below are some steps that I can think of. Please do a technical feasibility check for the below steps

 

  1. Set up a file upload component: Create a component in AEM that includes a file upload input field. This component will be used to render the file upload form on your live site. You can use HTML and AEM's component development features to create the form.

  2. Configure a DAM (Digital Asset Manager) folder for file storage: Set up a specific folder in AEM's DAM to store the uploaded files. Ensure that appropriate permissions are set for end users to upload and delete files in this folder.

  3. Handle file uploads in AEM: Implement a server-side script or servlet in AEM that handles the file upload process. This script will receive the uploaded file, validate it if necessary, and store it in the designated DAM folder. You can use AEM's API (e.g., AssetManager API) to manage the file upload process.

  4. Render uploaded files on the live site: Create a component or template that retrieves the uploaded files from the DAM folder and displays them on your live site. This component can use AEM's API (e.g., AssetManager API) to fetch the files from the DAM folder and render them as desired (e.g., as a list or gallery).

  5. Implement file deletion functionality: Add a feature to allow end users to delete files. This can be done by adding a delete button or checkbox for each uploaded file on the live site. When the user selects a file for deletion, you can implement a server-side script or servlet that handles the file deletion from the DAM folder using AEM's API.

  6. Apply appropriate security measures: Ensure that only authorized users have permissions to upload and delete files. Implement authentication and authorization mechanisms in AEM to control access to these features.

Avatar

Community Advisor

Hello @Mahesh_Gunaje - 

 

To implement a feature in AEM where end users can upload files (PDF/docs/images) and later download them, you have a few options:

 

1. Use of MongoDB to save the file:

  • You can use MongoDB as a binary storage solution to store the uploaded files.
  • In this approach, you would save the file in MongoDB and associate the file's metadata with AEM's resource or custom metadata.
  • However, this approach requires additional configuration and development effort to integrate MongoDB with AEM.

2. DAM folder:

  • You can create a DAM folder to store the uploaded files.
  • Users can upload the files through the DAM interface, and AEM will handle the storage and management of the files.
  • This is a convenient option as it leverages AEM's existing capabilities and provides a user-friendly interface for managing assets.
  • You can also control access permissions and metadata for the uploaded files.

3. AWS S3 (for non-AEM as a Cloud Service deployments):

  • If your AEM application is hosted in an AWS environment (not using AEM as a Cloud Service), you can leverage AWS S3 (Simple Storage Service) to store and retrieve the files.
  • AWS S3 provides scalable, secure, and durable storage for objects, including files. You can use the AWS SDK or APIs to integrate with S3 and upload/download files from your AEM application.
  • This approach offloads the storage and management of files to AWS, allowing you to take advantage of AWS features such as high availability, data replication, and scalability.

When choosing the appropriate approach, consider factors such as the scale of file storage, integration complexity, security requirements, and your existing infrastructure and preferences.

 

If you are already using AEM and want a straightforward solution, leveraging the DAM functionality is often a good choice.

Avatar

Level 8

Thanks @Tanika02  for your detailed solution. Long back, for one of the client, my team has used the mongodb approach.

 

Avatar

Community Advisor

@Mahesh_Gunaje - As said, you can very well use MongoDB. It's just that it would require some developmental efforts.