diff --git a/src/main/kotlin/com/nylas/resources/Attachments.kt b/src/main/kotlin/com/nylas/resources/Attachments.kt index d52ce2c4..2ef8ec86 100644 --- a/src/main/kotlin/com/nylas/resources/Attachments.kt +++ b/src/main/kotlin/com/nylas/resources/Attachments.kt @@ -55,6 +55,9 @@ class Attachments(client: NylasClient) : Resource(client, Attachment */ @Throws(NylasOAuthError::class, NylasSdkTimeoutError::class) fun downloadBytes(identifier: String, attachmentId: String, queryParams: FindAttachmentQueryParams): ByteArray { - return download(identifier, attachmentId, queryParams).bytes() + val download = download(identifier, attachmentId, queryParams) + val fileBytes = download.bytes() + download.close() + return fileBytes } }