diff --git a/components/google_drive/actions/create-file-from-text/create-file-from-text.mjs b/components/google_drive/actions/create-file-from-text/create-file-from-text.mjs index f46c902f23230..8114e26e48f1f 100644 --- a/components/google_drive/actions/create-file-from-text/create-file-from-text.mjs +++ b/components/google_drive/actions/create-file-from-text/create-file-from-text.mjs @@ -5,7 +5,7 @@ export default { key: "google_drive-create-file-from-text", name: "Create New File From Text", description: "Create a new file from plain text. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/create) for more information", - version: "0.1.7", + version: "0.2.0", type: "action", props: { googleDrive, @@ -44,24 +44,66 @@ export default { optional: true, default: "", }, + mimeType: { + type: "string", + label: "Conversion Format", + description: + "The [format](https://developers.google.com/drive/api/v3/ref-export-formats) in which the text is presented", + optional: true, + default: "text/plain", + options: [ + { + value: "text/plain", + label: "Plain Text", + }, + { + value: "text/markdown", + label: "Markdown", + }, + { + value: "text/html", + label: "HTML", + }, + { + value: "application/rtf", + label: "Rich Text", + }, + { + value: "text/csv", + label: "CSV", + }, + ], + }, }, async run({ $ }) { const { parentId, name, content, + mimeType, } = this; const file = Readable.from([ content, ]); + const drive = this.googleDrive.drive(); const driveId = this.googleDrive.getDriveId(this.drive); - const resp = await this.googleDrive.createFile({ - mimeType: "text/plain", - file, - name, - parentId, - driveId, + const parent = parentId ?? driveId; + + const { data: resp } = await drive.files.create({ + supportsAllDrives: true, + media: { + mimeType, + body: file, + }, + requestBody: { + name, + mimeType: "application/vnd.google-apps.document", + parents: [ + parent, + ], + }, }); + $.export("$summary", `Successfully created a new file, "${resp.name}"`); return resp; }, diff --git a/components/google_drive/package.json b/components/google_drive/package.json index 818797b532bd2..e15fcbab3225c 100644 --- a/components/google_drive/package.json +++ b/components/google_drive/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/google_drive", - "version": "0.8.7", + "version": "0.8.8", "description": "Pipedream Google_drive Components", "main": "google_drive.app.mjs", "keywords": [