Skip to content

FIX Infer Azure Blob MIME types from file extensions - #2315

Open
romanlutz wants to merge 2 commits into
microsoft:mainfrom
romanlutz:romanlutz-fix-blob-mime-types
Open

FIX Infer Azure Blob MIME types from file extensions#2315
romanlutz wants to merge 2 commits into
microsoft:mainfrom
romanlutz:romanlutz-fix-blob-mime-types

Conversation

@romanlutz

Copy link
Copy Markdown
Contributor

Description

Azure Blob payloads written through AzureBlobStorageIO currently receive the configured default text/plain metadata even when their filenames identify images, audio, video, or documents. This can cause downstream consumers to handle otherwise-correct bytes as text.

This change adds a private, deterministic extension-to-MIME mapping inside AzureBlobStorageIO.write_file_async, retaining the configured default for unknown or extensionless paths. It deliberately preserves the original two-argument StorageIO.write_file_async contract so existing third-party storage implementations remain compatible, and leaves AzureBlobStorageTarget's separate text-only content-type API unchanged.

Serializer filename handling now replaces an existing suffix instead of appending a duplicate one. Formatted PCM audio is always written as RIFF/WAVE with a .wav filename, allowing Azure metadata inference to set audio/wav, including when callers provide a filename with another extension.

This is a fresh replacement for the useful intent of closed PR #2233 without reusing its branch or broadening the public storage API.

Tests and Documentation

  • Added real-behavior unit coverage for representative text, image, audio, video, and document MIME metadata.
  • Added unknown-extension and extensionless fallback coverage.
  • Added WAV filename, RIFF/WAVE content, and audio/wav metadata coverage.
  • Added duplicate-extension and legacy custom StorageIO compatibility regressions.
  • Ran the targeted storage unit tests: 86 passed.
  • Ran targeted Ruff check and format validation; commit hooks including type checking also passed.
  • Documentation changes: N/A; behavior is internal and the public API is unchanged.
  • JupyText: N/A; no notebooks were changed.

Copilot AI added 2 commits August 2, 2026 17:28
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b06b3a6a-deb0-476e-a47e-d0f384760420
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b06b3a6a-deb0-476e-a47e-d0f384760420
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.

2 participants