@@ -18,7 +18,7 @@ export default {
1818 key : "google_drive-download-file" ,
1919 name : "Download File" ,
2020 description : "Download a file. [See the documentation](https://developers.google.com/drive/api/v3/manage-downloads) for more information" ,
21- version : "0.1.11 " ,
21+ version : "0.1.13 " ,
2222 type : "action" ,
2323 props : {
2424 googleDrive,
@@ -89,17 +89,17 @@ export default {
8989 } ) ;
9090 } ,
9191 } ,
92- getRawResponse : {
92+ getBufferResponse : {
9393 type : "boolean" ,
94- label : "Get Raw Response" ,
95- description : "Whether to return the file content directly in the response instead of writing to a file path" ,
94+ label : "Get Buffer Response" ,
95+ description : "Whether to return the file content as a buffer instead of writing to a file path" ,
9696 optional : true ,
9797 } ,
9898 } ,
9999 async run ( { $ } ) {
100100 // Validate that filePath is provided when not getting raw response
101- if ( ! this . getRawResponse && ! this . filePath ) {
102- throw new Error ( "File Path is required when not using Get Raw Response" ) ;
101+ if ( ! this . getBufferResponse && ! this . filePath ) {
102+ throw new Error ( "File Path is required when not using Get Buffer Response" ) ;
103103 }
104104
105105 // Get file metadata to get file's MIME type
@@ -125,11 +125,19 @@ export default {
125125 alt : "media" ,
126126 } ) ;
127127
128- if ( this . getRawResponse ) {
128+ if ( this . getBufferResponse ) {
129129 $ . export ( "$summary" , `Successfully retrieved raw content for file "${ fileMetadata . name } "` ) ;
130+
131+ // Convert stream to buffer
132+ const chunks = [ ] ;
133+ for await ( const chunk of file ) {
134+ chunks . push ( chunk ) ;
135+ }
136+ const buffer = Buffer . concat ( chunks ) ;
137+
130138 return {
131139 fileMetadata,
132- content : file ,
140+ content : buffer ,
133141 } ;
134142 }
135143
0 commit comments