Skip to content

Commit

Permalink
fix: improve Node.js stream type handling in form data
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-ai-integration[bot] committed Dec 24, 2024
1 parent 031b8ce commit a9568ac
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/resources/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,14 @@ export class Messages extends Resource {
const contentId = attachment.contentId || `file${index}`;
// Handle different types of content (Buffer, ReadableStream, string)
let file;
if (attachment.content instanceof ReadableStream || attachment.content instanceof Readable) {
// For ReadableStream or NodeJS.ReadableStream, use it directly as the file
if (attachment.content instanceof ReadableStream) {
// For web ReadableStream
file = attachment.content;
} else if (
// @ts-ignore - Check for Node.js Readable stream
typeof attachment.content?.pipe === 'function'
) {
// For Node.js streams (which have pipe method)
file = attachment.content;
} else if (
attachment.content instanceof Buffer ||
Expand Down

0 comments on commit a9568ac

Please sign in to comment.