Skip to content

Document file content response handling#1874

Open
Jaksenc wants to merge 1 commit into
openai:masterfrom
Jaksenc:codex/document-file-content-response
Open

Document file content response handling#1874
Jaksenc wants to merge 1 commit into
openai:masterfrom
Jaksenc:codex/document-file-content-response

Conversation

@Jaksenc
Copy link
Copy Markdown

@Jaksenc Jaksenc commented May 12, 2026

Summary

  • document that client.files.content() returns a web-standard Response and show reading it with .text()
  • align the exported FileContent alias with the actual response type

Closes #958.

Validation

  • git diff --check
  • npx --yes prettier@3.7.1 --check src/resources/files.ts
  • ./node_modules/.bin/tsc --noEmit --pretty false --target es2020 --lib es2020 --module commonjs --moduleResolution node --esModuleInterop --strict --skipLibCheck src/resources/files.ts

Note: full tsc --noEmit still requires optional example dependencies such as @azure/identity, express, and next.

@Jaksenc Jaksenc requested a review from a team as a code owner May 12, 2026 17:13
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c611b0a36d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread README.md Outdated

```ts
const response = await client.files.content('file-abc123');
const fileContents = await response.text();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use a binary-safe read method in file content example

Reading files.content() with response.text() only works for UTF-8 text files; for binary uploads (for example images, PDFs, or arbitrary user_data bytes), this decodes and corrupts the original byte stream. Since this snippet is presented as the general way to retrieve file contents, users following it for non-text files will get damaged data; the example should use a binary-safe method (such as arrayBuffer()) or clearly scope .text() to text-only files.

Useful? React with 👍 / 👎.

@Jaksenc Jaksenc force-pushed the codex/document-file-content-response branch from c611b0a to f3616cd Compare May 13, 2026 13:56
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.

openai.files.content returns raw Response object

1 participant