Skip to content

fix: render audio object previews natively - #200

Merged
cxymds merged 1 commit into
rustfs:mainfrom
ccccpj:agent/fix-audio-preview-5788
Aug 7, 2026
Merged

fix: render audio object previews natively#200
cxymds merged 1 commit into
rustfs:mainfrom
ccccpj:agent/fix-audio-preview-5788

Conversation

@ccccpj

@ccccpj ccccpj commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Pull Request

Description

Render object previews with normalized audio/* Content-Types through the browser's native <audio controls> element.

The previous generic fallback loaded audio inside iframe sandbox="". That sandbox creates an opaque origin, so ranged media requests can be sent as Origin: null and rejected by the object endpoint's CORS policy. The dedicated audio mode keeps the generic iframe sandbox strict, avoids broadening RustFS CORS, and avoids fetching entire objects into blobs.

Audio loading failures now render the existing localized Preview unavailable alert. Existing text, image, PDF, Parquet, TIFF, unknown-type, and no-URL behavior remains unchanged.

Type of Change

  • 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)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test improvements
  • Security fix

Testing

  • Unit tests added/updated
  • Manual testing completed
pnpm install --frozen-lockfile
pnpm type-check
pnpm lint
pnpm test:run
pnpm prettier --check components/object/preview-modal.tsx lib/object-preview.ts tests/lib/object-preview-source.test.js
git diff --check
  • pnpm test:run: 390/390 passed.
  • Deterministic local PCM WAV harness: the legacy sandbox path sent Origin: null with Range: bytes=0- and stayed at 0:00 / 0:00; the native audio path reached readyState=4, played to 2 seconds by keyboard, and received 206 Partial Content with no relevant browser errors.
  • pnpm format:check is currently blocked by an untouched upstream formatting issue in components/object/tiff-viewer.tsx; all files changed by this PR pass Prettier.

Checklist

  • Code follows the project's style guidelines
  • Self-review completed
  • TypeScript types are properly defined
  • All commit messages are in English (Conventional Commits)
  • All existing tests pass
  • No new dependencies added, or they are justified

Related Issues

Fixes rustfs/rustfs#5788

Screenshots (if applicable)

The captures below use a deterministic local harness with a valid 8 kHz mono PCM WAV and Content-Type: audio/wav. They demonstrate the preview DOM/media behavior without claiming a live RustFS deployment.

Before — generic sandbox iframe

Legacy audio preview displayed disabled controls at 0:00 / 0:00; DOM inspection confirmed iframe sandbox="", and the ranged media request carried Origin: null.

Before: WAV preview through the strict sandbox iframe

After — native audio controls

The native audio preview loaded the 2-second WAV, remained keyboard-operable, and completed playback with a normal Range/206 response.

After: WAV preview through native audio controls

Additional Notes

  • The generic iframe remains sandbox=""; this PR does not add allow-same-origin.
  • No RustFS backend CORS behavior is changed.
  • Explicit normalized audio/* MIME types take priority over extension-based Parquet/TIFF detection.
  • Independent reviewer, tester, UX auditor, and simplifier passes found no remaining blocking issues.

@cxymds cxymds self-assigned this Aug 7, 2026
@cxymds
cxymds marked this pull request as ready for review August 7, 2026 03:44
@cxymds
cxymds merged commit 7ea0a9d into rustfs:main Aug 7, 2026
10 checks passed
@cxymds

cxymds commented Aug 7, 2026

Copy link
Copy Markdown
Member

I noticed the two PRs you recently submitted. After reviewing the changes, I found that the modifications are very reasonable and well-designed.

Thank you very much for your contribution to RustFS! We really appreciate your time and effort in helping us improve the project.

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.

Wav preview failed

2 participants