Skip to content

fix: use correct DM delivery URLs per asset MIME type#832

Merged
auniverseaway merged 4 commits intoadobe:mainfrom
actinium15:fix/da-assets-dm-delivery-url-routing
Mar 19, 2026
Merged

fix: use correct DM delivery URLs per asset MIME type#832
auniverseaway merged 4 commits intoadobe:mainfrom
actinium15:fix/da-assets-dm-delivery-url-routing

Conversation

@actinium15
Copy link
Copy Markdown
Contributor

Summary

  • Documents (PDF, DOCX, CSV, ZIP) now route to /original instead of the web-optimized image delivery URL (/as/{name})
  • Videos route to /play by default
  • Both behaviours are configurable per-project: set aem.asset.document.mimetypes in the project config to a comma-separated list of MIME types that should use /original (overrides the defaults entirely, including for video MIME types if listed)

Routing logic (DM delivery mode)

Asset type URL suffix
MIME type in useOriginalMimetypes /original
video/* (not in above list) /play
Everything else (images, etc.) /as/{name}

Default aem.asset.document.mimetypes

application/pdf
application/vnd.openxmlformats-officedocument.wordprocessingml.document
text/csv
application/zip

Test plan

  • Select a PDF asset — verify URL ends with /original
  • Select a DOCX asset — verify URL ends with /original
  • Select a ZIP asset — verify URL ends with /original
  • Select a video asset — verify URL ends with /play
  • Select an image asset — verify URL ends with /as/{name}
  • Set aem.asset.document.mimetypes to video/mp4 in project config — verify MP4 asset URL ends with /original

Documents (PDF, DOCX, CSV, ZIP) now use /original instead of the
web-optimized image delivery URL. Videos use /play by default.
Both are configurable per-project via 'aem.asset.document.mimetypes'.
@actinium15
Copy link
Copy Markdown
Contributor Author

@sagarsane, @andreas-haller, could you please take a look?

I'm esp interested in knowing if the changes you intended to add via #806 are accounted for or not (they should be imo).

Comment thread blocks/edit/da-assets/da-assets.js Outdated
const ASSET_SELECTOR_URL = 'https://experience.adobe.com/solutions/CQ-assets-selectors/static-assets/resources/assets-selectors.js';

// MIME types that use /original rendition instead of web-optimized or /play delivery.
// Configurable per-project via 'aem.asset.document.mimetypes' (comma-separated).
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@auniverseaway @chrischrischris I'm thinking we probably don't need to configure this per project .. and by default only support whatever Dynamic Media OpenAPI supports (which is the list below). WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should have that config. two reasons:

  • the list isn't comprehensive since assets beyond these four may also require original download (pptx, doc, txt, ...) and DM with OpenAPI does support them
  • videos are interesting, because while /play is ideal, some customers may want to use mediabus to deliver mp4s and may require original there (and this can serve as an override)

- Original rendition: /original/as/{name} (was missing /as/{name})
- Web-optimized: /as/{baseName}.avif, always avif with extension stripped
return `${getBaseDmUrl(asset)}/original/as/${encodedName}`;
}
if (mimeType?.startsWith('video/')) {
return `${getBaseDmUrl(asset)}/play`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the author repository is configured for the asset selector, it's not guaranteed that the DM OpenAPI is enabled for the project, and /play endpoint may not be available, as I understand. @actinium15 thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

author repository is configured for the asset selector, it's not guaranteed that the DM OpenAPI is enabled for the project, and /play endpoint may not be available, as I understand

your understanding is correct.
afaict, author-repo flow ends a L140 with a return in if (!dmDeliveryEnabled) {} block. the .play endpoint changes are thus only applicable when dmDeliveryEnabled=true.

apologies if I'm going blind and missing something obvious here, @ravuthu

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@actinium15 The use case is that some customers choose the author Repo to have the folder structure even though the DM delivery is enabled.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some customers choose the author Repo to have the folder structure even though the DM delivery is enabled

as long as the code's generating urls that start with getBaseDmUrl (which the original code was doing as well here), the author/delivery/... repo won't matter.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understood the code correctly, dmDeliveryEnabled == true does not really mean that DM is enabled, but it means that the customer said they want to use the delivery tier.

To be 100% sure DM is enabled, is it possible to call the Discovery Service /index endpoint? In such a case, the Discovery Service returns "dmopenapi" as a value for "aem:solutions" property when Dynamic Media is enabled.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dmDeliveryEnabled == true does not really mean that DM is enabled

the current code (outside the context of this PR) switches completely to generating DM Urls when dmDeliveryEnabled==true.

is it possible to call the Discovery Service /index endpoint?

@pablomoreno61, are you suggesting that the assumption made in the code that's on mainline today is wrong?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that dmDeliveryEnabled is set in
const dmDeliveryEnabled = smartCropSelectEnabled || (await getConfKey(owner, repo, 'aem.asset.dm.delivery')) === 'on' || prodOrigin?.startsWith('delivery-');

I'm not knowledgeable about this repo, so take my opinion with a grain of salt. In that line of code, we are reading the properties set by the customer in their DA config file, right? If there is no previous validation, we are just "trusting" the input from the customer, but in the end, Dynamic Media could still be disabled for the AEM repository they targeted if they did not manually enable DM within AEM Experience Manager Cloud.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ravuthu, @sagarsane, the behaviour @pablomoreno61 notes (if valid) predates this changeset.

would you agree? if so, perhaps a candidate to address in a followup PR and move ahead with this changeset?

wdyt?

@ravuthu
Copy link
Copy Markdown
Contributor

ravuthu commented Mar 16, 2026

These are being discussed and taken care of on #841.

@auniverseaway, can you close this PR please?

Copy link
Copy Markdown
Contributor

@ravuthu ravuthu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me.

Copy link
Copy Markdown
Member

@auniverseaway auniverseaway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ravuthu & @sagarsane!

@auniverseaway auniverseaway merged commit 8cdfac7 into adobe:main Mar 19, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants