Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

AEM Cloud Service - Configure file upload max size per asset type, restrict upload from UI | AEM Community Blog Seeding

Avatar

Administrator

BlogImage.jpg

AEM Cloud Service - Configure file upload max size per asset type, restrict upload from UI by Sreekanth Choudry Nalabotu

Abstract

Goal
AEM Cloud Version : 2021.4.5226.20210427T070726Z-210325 (April 27, 2021)

Maximum asset size for uploads from AEM UI can be configured by overlaying /libs/dam/gui/content/assets/jcr:content/actions/secondary/create/items/fileupload@sizeLimit in /apps, however if the requirement is to configure limit per asset type (eg. jpg, png, mp4 etc.) the following extension could be useful....

1) Create a custom widget /apps/eaem-cs-restrict-assets-size/dam-tools/textfield/textfield.jsp to read the values from config resource /conf/global/settings/dam/eaem-dam-config

<%@include file="/libs/granite/ui/global.jsp" %>

<%@page session="false"
import="com.adobe.granite.ui.components.AttrBuilder,
com.adobe.granite.ui.components.Config,
com.adobe.granite.ui.components.Tag" %>
<%
Config cfg = cmp.getConfig();

String CONFIG_RES = "/conf/global/settings/dam/eaem-dam-config";
Resource configRes = resourceResolver.getResource(CONFIG_RES);

String name = cfg.get("name", String.class);
String value = "";

if(configRes != null){
value = configRes.getValueMap().get(name, String.class);
}

if(value == null){
value = cfg.get("defaultValue", String.class);
}

if(value == null){
value = "";
}

Tag tag = cmp.consumeTag();

AttrBuilder attrs = tag.getAttrs();
cmp.populateCommonAttrs(attrs);

attrs.add("name", name);

String fieldLabel = cfg.get("fieldLabel", String.class);
String fieldDesc = cfg.get("fieldDescription", String.class);
%>
<%=fieldDesc%>

2) Create the tools navigation /apps/cq/core/content/nav/tools/eaem-dam-tools/eaem-dam-config

?
1
2
3
4
5
6
7
8
9




3) Create the configuration page /apps/eaem-cs-restrict-assets-size/dam-tools/eaem-dam-config saving max upload limits to /conf/global/settings/dam/eaem-dam-config accessed using Tools > EAEM Configuration > EAEM Confi

Read Full Blog

AEM Cloud Service - Configure file upload max size per asset type, restrict upload from UI

Q&A

Please use this thread to ask the related questions.



Kautuk Sahni
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

0 Replies