Skip to content

Commit

Permalink
Fix inline attachments to sent correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Subash Pradhan committed Oct 31, 2024
1 parent e5a3440 commit c686f99
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

### Unreleased
* Fix issue where inline attachments > 3Mb were not sent correctly.

### 7.6.2 / 2024-10-31
* Add missing `select` field on query params
* Add missing `name` field on grant model
Expand Down
21 changes: 11 additions & 10 deletions src/resources/messages.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { AsyncListResponse, Resource } from './resource.js';
import FormData from 'form-data';
import APIClient, { RequestOptionsParams } from '../apiClient.js';
import { Overrides } from '../config.js';
import {
CreateDraftRequest,
SendMessageRequest,
UpdateDraftRequest,
} from '../models/drafts.js';
import {
CleanMessagesRequest,
CleanMessagesResponse,
Expand All @@ -10,21 +17,14 @@ import {
StopScheduledMessageResponse,
UpdateMessageRequest,
} from '../models/messages.js';
import { Overrides } from '../config.js';
import {
NylasBaseResponse,
NylasListResponse,
NylasResponse,
} from '../models/response.js';
import {
CreateDraftRequest,
SendMessageRequest,
UpdateDraftRequest,
} from '../models/drafts.js';
import FormData from 'form-data';
import { encodeAttachmentStreams, objKeysToSnakeCase } from '../utils.js';
import { AsyncListResponse, Resource } from './resource.js';
import { SmartCompose } from './smartCompose.js';
import APIClient, { RequestOptionsParams } from '../apiClient.js';

/**
* The parameters for the {@link Messages.list} method
Expand Down Expand Up @@ -325,7 +325,8 @@ export class Messages extends Resource {

// Add a separate form field for each attachment
requestBody.attachments?.forEach((attachment, index) => {
form.append(`file${index}`, attachment.content, {
const contentId = attachment.contentId || `file${index}`;
form.append(contentId, attachment.content, {
filename: attachment.filename,
contentType: attachment.contentType,
});
Expand Down

0 comments on commit c686f99

Please sign in to comment.