Skip to content

Commit

Permalink
style: fix prettier formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-ai-integration[bot] committed Dec 24, 2024
1 parent 18fd2f1 commit 6469f34
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export default class APIClient {
const encoder = new FormDataEncoder(optionParams.form);
requestOptions.headers = {
...requestOptions.headers,
'content-type': encoder.contentType
'content-type': encoder.contentType,
};
}

Expand Down
13 changes: 10 additions & 3 deletions src/resources/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,13 @@ 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 Buffer || typeof attachment.content === 'string') {
file = new File([attachment.content], attachment.filename, { type: attachment.contentType });
if (
attachment.content instanceof Buffer ||
typeof attachment.content === 'string'
) {
file = new File([attachment.content], attachment.filename, {
type: attachment.contentType,
});
} else if (attachment.content instanceof ReadableStream) {
// For ReadableStream, we need to read it into a buffer first
const chunks: Buffer[] = [];
Expand All @@ -338,7 +343,9 @@ export class Messages extends Resource {
result = await reader.read();
}
const buffer = Buffer.concat(chunks);
file = new File([buffer], attachment.filename, { type: attachment.contentType });
file = new File([buffer], attachment.filename, {
type: attachment.contentType,
});
} else {
throw new Error('Unsupported attachment content type');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/messages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jest.mock('formdata-node', () => {
};

this._getAppendedData = (): Record<string, any> => appendedData;
})
}),
};
});

Expand Down

0 comments on commit 6469f34

Please sign in to comment.