File tree Expand file tree Collapse file tree 1 file changed +3
-12
lines changed
Expand file tree Collapse file tree 1 file changed +3
-12
lines changed Original file line number Diff line number Diff line change @@ -334,18 +334,9 @@ export class Messages extends Resource {
334334 type : attachment . contentType ,
335335 } ) ;
336336 } else if ( attachment . content instanceof ReadableStream ) {
337- // For ReadableStream, we need to read it into a buffer first
338- const chunks : Buffer [ ] = [ ] ;
339- const reader = attachment . content . getReader ( ) ;
340- let result = await reader . read ( ) ;
341- while ( ! result . done ) {
342- chunks . push ( Buffer . from ( result . value ) ) ;
343- result = await reader . read ( ) ;
344- }
345- const buffer = Buffer . concat ( chunks ) ;
346- file = new File ( [ buffer ] , attachment . filename , {
347- type : attachment . contentType ,
348- } ) ;
337+ // For ReadableStream, append it directly to the form
338+ form . append ( contentId , attachment . content , attachment . filename ) ;
339+ continue ;
349340 } else {
350341 throw new Error ( 'Unsupported attachment content type' ) ;
351342 }
You can’t perform that action at this time.
0 commit comments