Recommended way for content disposition configuration | Community
Skip to main content
Kishore_Kumar_
Level 9
Aug 20, 2021 11:15 AM UTC
Solved

Recommended way for content disposition configuration

Hi guys,

 

Suppose if i want to allow the PDFs to view in browser instead of downloading, May i know which method is recommended way to do it ?

 

1. Setting content disposition config in dispatcher

 

or

 

2. Allowing it through Apache Sling Content Disposition Filter (org.apache.sling.security.impl.ContentDispositionFilter) OSGI Configuration ?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Asutosh_Jena_
Asutosh_Jena_Accepted solution
New Participant
Aug 20, 2021 1:48 PM UTC

It will disable the disposition filter for all, Considering security i don't want to disable for all, for time being i need only for PDF. So checking if there is a way to exclude filter only for it.


@kishore_kumar_ I believe your dispatcher would have taken care of all the security measures. But if you do not want to disable this completely then you can go for the below option. It will enable the filter on all path except pdfs under /content.

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
sling.content.disposition.paths="[/content/*:application/pdf]"/>

 

7 replies

Asutosh_Jena_
New Participant
Aug 20, 2021 12:43 PM UTC

Hi @kishore_kumar_ 

 

It is recommended to keep the configs at the OSGi level if it can be re-used across instances. So in this case I believe you want to apply this specific rules on all the publish instance or on all instance.

So keeping it at the OSGi level will be the recommended here.

 

org.apache.sling.security.impl.ContentDispositionFilter.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
sling.content.disposition.all.paths="{Boolean}false"
sling.content.disposition.excluded.paths="[/content/project/abc/pdf1.pdf,/content/project/abc/pdf1.pdf]"/>

 

Here is an article regarding the same:

http://www.sgaemsolutions.com/2019/10/aempdf-is-getting-downloded-instead-of.html

 

Hope this helps!

Thanks! 

Translate
Kishore_Kumar_
Level 9
Aug 20, 2021 12:48 PM UTC

Thanks for you reply @asutosh_jena_ , But still regex/wildcard is not supported for Excluded Paths i guess. If i want to allow for all the PDFs may i know how to do it ?  

 

Allowing wildcard request reference ticket still no updates.

https://issues.apache.org/jira/browse/SLING-6106 

 

Translate
Asutosh_Jena_
New Participant
Aug 20, 2021 1:20 PM UTC

@kishore_kumar_  If you want to apply for all the PDFs then you can just add the below config and it will take care.

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
sling.content.disposition.all.paths="{Boolean}false"/>

Thanks! 

Translate
Bhuwan_B
New Participant
Aug 20, 2021 11:29 AM UTC

@kishore_kumar_  You can implement your usecase using Apache Sling Content Disposition Filter [Refer below Documentation].

https://experienceleague.adobe.com/docs/experience-manager-65/administering/security/content-disposition-filter.html?lang=en

Note: I dont see any cons acheiving it through dispatcher either but Apache Sling Content Disposition Filter is what i see in the documentation.

Translate