<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to compare the size of the asset uploaded with the value from my custom OSGi configuration? in Adobe Experience Manager Questions</title>
    <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452326#M129792</link>
    <description>&lt;P&gt;I tried with this snippet but getting this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ac6600_0-1652819808696.png" style="width: 400px;"&gt;&lt;img src="https://experienceleaguecommunities.adobe.com/t5/image/serverpage/image-id/41049iB0FA83E9F5192AB6/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="ac6600_0-1652819808696.png" alt="ac6600_0-1652819808696.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Do I need to import anything?&amp;nbsp;&lt;LI-USER uid="11813833"&gt;&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 May 2022 20:37:15 GMT</pubDate>
    <dc:creator>ac6600</dc:creator>
    <dc:date>2022-05-17T20:37:15Z</dc:date>
    <item>
      <title>How to compare the size of the asset uploaded with the value from my custom OSGi configuration?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452294#M129777</link>
      <description>&lt;P&gt;I have created an OSGi Config as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ac6600_0-1652810995515.png" style="width: 400px;"&gt;&lt;img src="https://experienceleaguecommunities.adobe.com/t5/image/serverpage/image-id/41041iEA998725FD5186D6/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="ac6600_0-1652810995515.png" alt="ac6600_0-1652810995515.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I am reading the values like:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ac6600_1-1652811036475.png" style="width: 400px;"&gt;&lt;img src="https://experienceleaguecommunities.adobe.com/t5/image/serverpage/image-id/41042i2B9741F7831BB2AF/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="ac6600_1-1652811036475.png" alt="ac6600_1-1652811036475.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Now, what I want to do is I want to compare the size of the asset file uploaded with assetSize value [from OSGi] when activated = true. And if size of asset file &amp;gt; assetSize, then the asset won't get uploaded to DAM and will show a error message.&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 18:13:43 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452294#M129777</guid>
      <dc:creator>ac6600</dc:creator>
      <dc:date>2022-05-17T18:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the size of the asset uploaded with the value from my custom OSGi configuration?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452311#M129786</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;LI-USER uid="17473051"&gt;&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;AssetDetails asset = new AssetDetails(assetResource);
asset.getOriginal.getsize();
if(asset.getSize() &amp;lt; assetSize) {
     // Do Something
}&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Asset API:&lt;SPAN&gt;&amp;nbsp;&lt;A href="https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/adobe/granite/asset/api/Asset.html" target="_blank" rel="noopener"&gt;https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/adobe/granite/asset/api/Asset.html&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Rendition API:&lt;SPAN&gt;&amp;nbsp;&lt;A href="https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/dam/api/Rendition.html" target="_blank" rel="noopener"&gt;https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/dam/api/Rendition.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Hope that helps you!&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Santosh&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 19:46:16 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452311#M129786</guid>
      <dc:creator>SantoshSai</dc:creator>
      <dc:date>2022-05-17T19:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the size of the asset uploaded with the value from my custom OSGi configuration?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452323#M129790</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;LI-USER uid="11813833"&gt;&lt;/LI-USER&gt;&amp;nbsp;, thanks for the solve. One more thing(maybe a dumb question), where shall I write this piece of code. Like will this be part of servlet or shall I write this within the OSGi config or anything else?&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 20:32:02 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452323#M129790</guid>
      <dc:creator>ac6600</dc:creator>
      <dc:date>2022-05-17T20:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the size of the asset uploaded with the value from my custom OSGi configuration?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452324#M129791</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;LI-USER uid="17473051"&gt;&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I wound't do it in servlet, However, you can implement it in same class where you are reading configuration values by creating separate method or in separate service component.&lt;BR /&gt;&lt;BR /&gt;Hope that helps!&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Santosh&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 20:36:29 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452324#M129791</guid>
      <dc:creator>SantoshSai</dc:creator>
      <dc:date>2022-05-17T20:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the size of the asset uploaded with the value from my custom OSGi configuration?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452326#M129792</link>
      <description>&lt;P&gt;I tried with this snippet but getting this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ac6600_0-1652819808696.png" style="width: 400px;"&gt;&lt;img src="https://experienceleaguecommunities.adobe.com/t5/image/serverpage/image-id/41049iB0FA83E9F5192AB6/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="ac6600_0-1652819808696.png" alt="ac6600_0-1652819808696.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Do I need to import anything?&amp;nbsp;&lt;LI-USER uid="11813833"&gt;&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 20:37:15 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452326#M129792</guid>
      <dc:creator>ac6600</dc:creator>
      <dc:date>2022-05-17T20:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the size of the asset uploaded with the value from my custom OSGi configuration?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452328#M129793</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;LI-USER uid="17473051"&gt;&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Tried in Servlet&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-05-17 at 4.53.07 PM.png" style="width: 525px;"&gt;&lt;img src="https://experienceleaguecommunities.adobe.com/t5/image/serverpage/image-id/41050iAB425B90BF3E7D42/image-dimensions/525x154/is-moderation-mode/true?v=v2" width="525" height="154" role="button" title="Screen Shot 2022-05-17 at 4.53.07 PM.png" alt="Screen Shot 2022-05-17 at 4.53.07 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;com.day.cq.dam.api.Asset;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Regards,&lt;BR /&gt;Santosh&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 20:55:26 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452328#M129793</guid>
      <dc:creator>SantoshSai</dc:creator>
      <dc:date>2022-05-17T20:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the size of the asset uploaded with the value from my custom OSGi configuration?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452336#M129796</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;LI-USER uid="11813833"&gt;&lt;/LI-USER&gt;&amp;nbsp;if you don't mind, can you share the entire code that I need to write in servlet in order to achieve this functionality.&lt;BR /&gt;&lt;BR /&gt;Thank you for all the help rendered.&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 22:15:26 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452336#M129796</guid>
      <dc:creator>ac6600</dc:creator>
      <dc:date>2022-05-17T22:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the size of the asset uploaded with the value from my custom OSGi configuration?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452341#M129797</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;LI-USER uid="17473051"&gt;&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;/*
 *  Copyright 2015 Adobe Systems Incorporated
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.mysite.core.servlets;

import com.day.cq.commons.jcr.JcrConstants;
import com.day.cq.dam.api.Asset;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.servlets.HttpConstants;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
import org.apache.sling.servlets.annotations.SlingServletResourceTypes;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.propertytypes.ServiceDescription;

import javax.servlet.Servlet;
import javax.servlet.ServletException;
import java.io.IOException;

/**
 * Servlet that writes some sample content into the response. It is mounted for
 * all resources of a specific Sling resource type. The
 * {@link SlingSafeMethodsServlet} shall be used for HTTP methods that are
 * idempotent. For write operations use the {@link SlingAllMethodsServlet}.
 */
@Component(service = { Servlet.class })
@SlingServletResourceTypes(
        resourceTypes="mysite/components/page",
        methods=HttpConstants.METHOD_GET,
        extensions="txt")
@ServiceDescription("Simple Demo Servlet")
public class SimpleServlet extends SlingSafeMethodsServlet {

    private static final long serialVersionUID = 1L;

    @Override
    protected void doGet(final SlingHttpServletRequest req,
            final SlingHttpServletResponse resp) throws ServletException, IOException {
        final Resource resource = req.getResource();

        Asset asset = resource.adaptTo(Asset.class);
        asset.getOriginal().getSize();

        resp.setContentType("text/plain");
        resp.getWriter().write("Title = " + resource.getValueMap().get(JcrConstants.JCR_TITLE));
    }
}&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Santosh&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 01:06:33 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452341#M129797</guid>
      <dc:creator>SantoshSai</dc:creator>
      <dc:date>2022-05-18T01:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the size of the asset uploaded with the value from my custom OSGi configuration?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452533#M129856</link>
      <description>&lt;P&gt;The problem is that you need to hook into the asset upload process itself somehow. At best in a way, that terminates the request as soon as it crosses the configured value in the request body's size.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In AEM 6.x I don't think that there is a public API for it, and in AEM CS it is not possible at all, because the upload itself does not happen via the JVM at all.&lt;/P&gt;&lt;P&gt;The best way is either to restrict the frontend to prevent selecting larger assets to handle the cases when they are already uploaded.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 18:35:05 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-compare-the-size-of-the-asset-uploaded-with-the-value/m-p/452533#M129856</guid>
      <dc:creator>Jörg_Hoh</dc:creator>
      <dc:date>2022-05-18T18:35:05Z</dc:date>
    </item>
  </channel>
</rss>

