Skip to content

Preserve MIME type in toFile#1951

Open
fallintoplace wants to merge 1 commit into
openai:mainfrom
fallintoplace:fix/tofile-preserve-mime
Open

Preserve MIME type in toFile#1951
fallintoplace wants to merge 1 commit into
openai:mainfrom
fallintoplace:fix/tofile-preserve-mime

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

Summary

  • Preserve MIME type and lastModified when toFile() clones File-like objects.
  • Default Response-derived files to the blob MIME type when the caller did not pass one.
  • Fix Blob part MIME type inference by reading part.type instead of checking the matched part object.

Why

Some upload inputs were converted into new File objects without carrying their content type forward. That could leave files with an empty MIME type even when the original Blob, File-like object, or Response body had one.

Validation

  • ./node_modules/.bin/jest tests/uploads.test.ts --runInBand
  • ./node_modules/.bin/prettier --check src/internal/to-file.ts tests/uploads.test.ts
  • ./node_modules/.bin/eslint src/internal/to-file.ts tests/uploads.test.ts
  • ./node_modules/typescript/bin/tsc
  • ./scripts/build

@fallintoplace fallintoplace requested a review from a team as a code owner June 23, 2026 18:22
@HAYDEN-OAI HAYDEN-OAI added the upstream Needs to be addressed in Stainless upstream label Jun 23, 2026 — with ChatGPT Codex Connector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upstream Needs to be addressed in Stainless upstream

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants