fix: use correct DM delivery URLs per asset MIME type#832
fix: use correct DM delivery URLs per asset MIME type#832auniverseaway merged 4 commits intoadobe:mainfrom
Conversation
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'.
|
@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). |
| 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). |
There was a problem hiding this comment.
@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?
There was a problem hiding this comment.
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
/playis 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`; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
author repository is configured for the asset selector, it's not guaranteed that the DM OpenAPI is enabled for the project, and
/playendpoint 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
There was a problem hiding this comment.
@actinium15 The use case is that some customers choose the author Repo to have the folder structure even though the DM delivery is enabled.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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?
|
These are being discussed and taken care of on #841. @auniverseaway, can you close this PR please? |
ravuthu
left a comment
There was a problem hiding this comment.
Changes look good to me.
auniverseaway
left a comment
There was a problem hiding this comment.
Thanks @ravuthu & @sagarsane!
Summary
/originalinstead of the web-optimized image delivery URL (/as/{name})/playby defaultaem.asset.document.mimetypesin 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)
useOriginalMimetypes/originalvideo/*(not in above list)/play/as/{name}Default
aem.asset.document.mimetypesTest plan
/original/original/original/play/as/{name}aem.asset.document.mimetypestovideo/mp4in project config — verify MP4 asset URL ends with/original