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

Preventing uploading of images that do not conform to a specific size

Avatar

Level 2

We want to write a handler to throw error back to the user while uploading an image if it does not conform to standard height and width. What's the best and recommended way to do this?

How to read asset being uploaded and extract it's size before allowing it to be uploaded?

1 Accepted Solution

Avatar

Correct answer by
Administrator

Hi 

Please have a look at this forum post discussing similar use case.

Link 1:-http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage...

// How to decline image upload when the size of the image is more than the expected?

    Write a custom Sling Servlet that uploads DAM Assets. In the Sling Servlet - use the Asset Manager API. You have full control and if the asset is larger than you want, you can prevent it from going into               the DAM. See this article on how to use Asset Manager API: 

    https://helpx.adobe.com/experience-manager/using/uploading-files-aem1.html

Read all the comments.

 

Link 2:- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage...

// Restrict file uploads by size & type in DAM upload dialog

 

I hope this will help you.

~kautuk



Kautuk Sahni

View solution in original post

2 Replies

Avatar

Correct answer by
Administrator

Hi 

Please have a look at this forum post discussing similar use case.

Link 1:-http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage...

// How to decline image upload when the size of the image is more than the expected?

    Write a custom Sling Servlet that uploads DAM Assets. In the Sling Servlet - use the Asset Manager API. You have full control and if the asset is larger than you want, you can prevent it from going into               the DAM. See this article on how to use Asset Manager API: 

    https://helpx.adobe.com/experience-manager/using/uploading-files-aem1.html

Read all the comments.

 

Link 2:- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage...

// Restrict file uploads by size & type in DAM upload dialog

 

I hope this will help you.

~kautuk



Kautuk Sahni

Avatar

Level 10

As Kautuk suggest - you need to perform this operation in a Sling Servlet. See the article that Kautuk points to as it shows you the syntax you need to handle files via a Sling Servlet. You would use Java logic to test the image and if it fails - do not process the file. If it passes - use the AssetManager API to process the file.