Skip to content

[AEM] Support assets without file extensions - #87

Merged
blefebvre merged 4 commits into
mainfrom
blefebvr/handle-extensionless-assets
Mar 4, 2026
Merged

[AEM] Support assets without file extensions#87
blefebvre merged 4 commits into
mainfrom
blefebvr/handle-extensionless-assets

Conversation

@blefebvre

@blefebvre blefebvre commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Description

Support S7 image URLs, and others which do not include a file extension. AEM determines an asset's MIME type from its file extension during upload, so the import helper now does some detective work to determine the correct extension to apply and then updates the .xml documents as needed with the new (complete) filename.

  • MIME type detection (src/utils/mime-utils.js) — New module that detects file types by inspecting magic bytes and SVG content. Supports PNG, JPEG, GIF (87a/89a), BMP, ICO, TIFF, WebP, AVIF, HEIC/HEIF, SVG, and PDF. Extensionless files in the asset directory are renamed with the correct extension before upload (e.g. our-hero → our-hero.jpg). The function returns a map of old → new paths for downstream processing.
  • Content package XML updates (src/aem/package-modifier.js) — Added buildExtensionReplacementMap() which converts the filesystem rename map into JCR path replacements (e.g. /content/dam/site/our-hero → /content/dam/site/our-hero.jpg). These replacements are merged with the existing PNG conversion replacements and applied to all .content.xml files in the package, keeping asset references in sync.
  • Upload pipeline (src/aem/upload-assets.js, src/aem/cmd-handler.js) — uploadAssets now returns { uploadResult, renamedFiles }. The command handler uses the rename map to build JCR replacements and passes them to prepareModifiedPackage.
  • Download behaviour (src/utils/download-assets.js) — Removed the previous logic that added extensions during download based on Content-Type headers. Extensions are now assigned solely by content inspection before upload, ensuring the rename map is always populated and .content.xml references are always updated.

Motivation and Context

Specifically, we now correctly handle S7 URLs that lack a file extension.

How Has This Been Tested?

  • Unit tests
  • Manual testing

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@blefebvre
blefebvre requested a review from bhellema March 3, 2026 21:34
@blefebvre blefebvre self-assigned this Mar 3, 2026
@github-actions

github-actions Bot commented Mar 3, 2026

Copy link
Copy Markdown

This PR will trigger no release when merged.

@blefebvre
blefebvre merged commit 47fbf48 into main Mar 4, 2026
6 checks passed
@blefebvre
blefebvre deleted the blefebvr/handle-extensionless-assets branch March 4, 2026 00:07
@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants