Serve DAM based html page as html... | Community
Skip to main content
Peter_Puzanovs
Community Advisor
Community Advisor
October 16, 2015
Solved

Serve DAM based html page as html...

  • October 16, 2015
  • 6 replies
  • 4514 views

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

 

Thanks,

Peter

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by

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?apply=true&action=ajaxConfigManager&cq.mime.type.blacklist=application/octet-stream&propertylist=sling.servlet.resourceTypes,sling.servlet.methods,cq.mime.type.blacklist,cq.dam.empty.mime'

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

6 replies

smacdonald2008
October 16, 2015

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? 

October 16, 2015

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.

Accepted solution
October 16, 2015

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?apply=true&action=ajaxConfigManager&cq.mime.type.blacklist=application/octet-stream&propertylist=sling.servlet.resourceTypes,sling.servlet.methods,cq.mime.type.blacklist,cq.dam.empty.mime'

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

Adobe Employee
August 23, 2022

Does this work in AEMaaCS as well?

Peter_Puzanovs
Community Advisor
Community Advisor
October 16, 2015

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

Peter_Puzanovs
Community Advisor
Community Advisor
October 16, 2015

Perfect answer, thank you for your help Mr Kumar !

Peter

naresh5361
November 18, 2022

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

 

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.