• Home
  • Culture
  • Offices
  • Jobs
  • Blog
  • Contact
  • Home
  • Culture
  • Offices
  • Jobs
  • Blog
  • Contact

Serving Assets with Selectors

  • Christoph Thommen
  • 12.08.2016

In a project, we recently had the requirement to serve assets with a selector. The reason for adding the selector was that all CUG protected assets need to be served from an specific dispatcher farm.

Unfortunately, the extension of assets is part of the node name in AEM. A sample geometrixx asset is stored as node “GeoCube_Datasheet.pdf” under /content/dam/geometrixx/documents .

When we try to access this with a selector /content/dam/geometrixx/documents/GeoCube_Datasheet.secure.pdf, the resource cannot be resolved, resulting in a 404.

After checking the Sling source code, we’ve found a way to get to the document with the selector: add all the selectors after the extension, and then add extension .res.

Why? that’s quite complicated:

  • adding the selectors after the original extension makes sure that the resource is actually found during resource resolution
  • rendering of resources needs to be done by the org.apache.sling.servlets.get.impl.helpers.StreamRendererServlet, but the servlet only accepts resources without an extension or with .res

But our troubles are not quite over yet: If we render this as a .res resource, Apache will serve this as content type application/x‐dtbresource+xml

The following rewrite rule should take care of that for pdf documents:

RewriteRule ^/content/dam/(.*).secure.pdf /content/dam/$1.pdf.secure.res [PT,L,T=application/pdf]

With this rewrite rule, the asset is actually available for end users at the desired url /content/dam/geometrixx/documents/GeoCube_Datasheet.secure.pdf, hiding the .res extension workaround from the end user.

Search

Latest Post

AEM TouchUI dropdown mandatory validation

Right-To-Left Keyboard Switch for Granite / Touch UI

TouchUI Page Properties encoding issue with AEM 6.2 CFP3

Serving Assets with Selectors

Why components are not shown the in CoralUI Component Browser

Contact & Legal Info

Codeflair AG

Sissacherstrasse 20

CH-4460 Gelterkinden

+41 61 508 50 65

contact@codeflair.ch

We are Hiring!
  • Are you a seriously good Java developer or architect, ideally with CQ/AEM knowhow? Do you even know AngularJS and the ionic framework?

See our open positions here

Related Articles

Here, you can find interesting bits and pieces we find in our work and about codeflair itself.

AEM Touch UI

AEM TouchUI dropdown mandatory validation

Christoph Thommen November 2, 2019

In AEM 6.2, there is no mandatory validation for dropdowns in dialogs, when having a “Please select” option in place. This is due to a validation check in the out

AEM Validator

Right-To-Left Keyboard Switch for Granite / Touch UI

Christoph Thommen November 2, 2019

In the AEM classic UI, an author entering text in Hebrew can switch the editor to right-to-left mode with the keyboard shortcut ctrl-shift-x. Unfortunately, this is not possible anymore in

TouchUI Page Properties encoding issue with AEM 6.2 CFP3

Christoph Thommen June 2, 2017

While implementing a new website based on AEM 6.2 CFP3 for a customer, we faced the following problem: When editing page properties right from “Sites” > “View Properties”, the encoding

Codeflair AG is a registered Swiss stock company with its headquarter in Gelterkinden (BL) and a subsidiary in Skopje, North Macedonia.

The main focus of the company is to provide high quality software services in the enterprise market using CMS software like Adobe Experience Manger (AEM), Sitecore or micro service-based portals in combination with latest frontend technologies.

Instagram

Copyright © 2019. All rights reserved.

Impressum & Privacy Policy

CONTACT & LEGAL INFO

codeflair AG

Sissacherstrasse 20

CH-4460 Gelterkinden

+41 61 508 50 65

contact@codeflair.ch

QUICK LINKS
  • Homepage
  • Our Culture
  • Offices
  • Jobs
  • Blog
Menu
  • Homepage
  • Our Culture
  • Offices
  • Jobs
  • Blog