Expand my Community achievements bar.

SOLVED

Serve DAM based html page as html...

Avatar

Community Advisor

Quick question, what needs to be changed to serve html page in DAM as a text/html and not application/save...

 

Thanks,

Peter

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

One of my client had similar requirements and after some analysis(mentioned below) I could render the html from /content/dam path.  

So a DAM Asset is served by the BinaryProviderServlet and after doing its own stuff it dispatches the request to another servlet called SafeBinaryGetServlet which will either render the resource or ask the browser to save it based on the mime:type of the resource is in black list or not, since the “text/html” is registered as a blacklist mime type by the SafeBinaryGetServlet. And for that black list it sets a “content-disposition:attachment” header with attachment as an option, its a direction to the browser to download the file and not render it. Hope this is clear till now.

Note: Make sure you do impact analysis of the change I am suggesting below.

Run this curl command to have the configuration removed from OSGI web console.

curl -u admin:admin -X POST 'http://localhost:4502/system/console/configMgr/com.day.cq.dam.core.impl.servlet.SafeBinaryGetServlet...'

Or

Directly go to AEM Web console - http://localhost:4502/system/console/configMgr/com.day.cq.dam.core.impl.servlet.SafeBinaryGetServlet

and remove the text/html entry from config, save it.

Also, the better place to put such artefacts is /content/campaign

That way the above mentioned restrictions will not come into picture and the content will be served properly without any explicit changes.

Thanks,

Rakesh

View solution in original post

7 Replies

Avatar

Level 10

Can you please describe what you are tying to do? If you want to serve up an  HTML page that shows DAM assets - why not simply write a component that uses HTML and app logic to get DAM assets and display in the HTML? 

Avatar

Former Community Member

Also, the better place to put such artefacts is /content/campaign

That way the above mentioned restrictions will not come into picture and the content will be served properly.

Avatar

Correct answer by
Former Community Member

One of my client had similar requirements and after some analysis(mentioned below) I could render the html from /content/dam path.  

So a DAM Asset is served by the BinaryProviderServlet and after doing its own stuff it dispatches the request to another servlet called SafeBinaryGetServlet which will either render the resource or ask the browser to save it based on the mime:type of the resource is in black list or not, since the “text/html” is registered as a blacklist mime type by the SafeBinaryGetServlet. And for that black list it sets a “content-disposition:attachment” header with attachment as an option, its a direction to the browser to download the file and not render it. Hope this is clear till now.

Note: Make sure you do impact analysis of the change I am suggesting below.

Run this curl command to have the configuration removed from OSGI web console.

curl -u admin:admin -X POST 'http://localhost:4502/system/console/configMgr/com.day.cq.dam.core.impl.servlet.SafeBinaryGetServlet...'

Or

Directly go to AEM Web console - http://localhost:4502/system/console/configMgr/com.day.cq.dam.core.impl.servlet.SafeBinaryGetServlet

and remove the text/html entry from config, save it.

Also, the better place to put such artefacts is /content/campaign

That way the above mentioned restrictions will not come into picture and the content will be served properly without any explicit changes.

Thanks,

Rakesh

Avatar

Community Advisor

Hi Scott,

That's exactly what was offered from us. However, team that wanted this featured required a 'simple' solution to store files and get benefits of the CDN network that is setup for the CQ5 infrastructure(.e.g. custom cache busting and other features that come in hand when content is stored in DAM)

Peter

Avatar

Community Advisor

Perfect answer, thank you for your help Mr Kumar !

Peter

Avatar

Level 2

Hi All,

Does this work in AEMaaCS as well? 

 

I have done the changes but still i am not able to see the html content on dam asset.

http://localhost:4502/system/console/configMgr/com.day.cq.dam.core.impl.servlet.SafeBinaryGetServlet...

removed text/html from this config .

http://localhost:4502/assetdetails.html/content/dam/test.html

Screen Shot 2022-11-18 at 12.15.09 PM.png

 

reproduce:

1. create .html file add normal html content.

2. upload into dam post processing click on the asset.

3. it is opening like a bove screenshot. 

 

currenly we are using aem as cloud service. 

 

thanks in advance.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----