diff --git a/README.md b/README.md index 26b0dfa9e..dcb85c02d 100644 --- a/README.md +++ b/README.md @@ -223,6 +223,16 @@ await client.files.create({ }); ``` +To retrieve uploaded file contents, use `files.content()` and consume the returned +web standard `Response`: + +```ts +const response = await client.files.content('file-abc123'); +const fileContents = await response.arrayBuffer(); +``` + +For text files, you can use `await response.text()` instead. + ## Webhook Verification Verifying webhook signatures is _optional but encouraged_. diff --git a/src/resources/files.ts b/src/resources/files.ts index 227128209..374a5f5a3 100644 --- a/src/resources/files.ts +++ b/src/resources/files.ts @@ -120,7 +120,7 @@ export class Files extends APIResource { export type FileObjectsPage = CursorPage; -export type FileContent = string; +export type FileContent = Response; export interface FileDeleted { id: string;