Skip to content

Commit 5c394df

Browse files
Google Drive - allow format selection for text (#15299)
* allow format selection * typo * bump version
1 parent 4705140 commit 5c394df

File tree

2 files changed

+50
-8
lines changed

2 files changed

+50
-8
lines changed

components/google_drive/actions/create-file-from-text/create-file-from-text.mjs

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "google_drive-create-file-from-text",
66
name: "Create New File From Text",
77
description: "Create a new file from plain text. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/create) for more information",
8-
version: "0.1.7",
8+
version: "0.2.0",
99
type: "action",
1010
props: {
1111
googleDrive,
@@ -44,24 +44,66 @@ export default {
4444
optional: true,
4545
default: "",
4646
},
47+
mimeType: {
48+
type: "string",
49+
label: "Conversion Format",
50+
description:
51+
"The [format](https://developers.google.com/drive/api/v3/ref-export-formats) in which the text is presented",
52+
optional: true,
53+
default: "text/plain",
54+
options: [
55+
{
56+
value: "text/plain",
57+
label: "Plain Text",
58+
},
59+
{
60+
value: "text/markdown",
61+
label: "Markdown",
62+
},
63+
{
64+
value: "text/html",
65+
label: "HTML",
66+
},
67+
{
68+
value: "application/rtf",
69+
label: "Rich Text",
70+
},
71+
{
72+
value: "text/csv",
73+
label: "CSV",
74+
},
75+
],
76+
},
4777
},
4878
async run({ $ }) {
4979
const {
5080
parentId,
5181
name,
5282
content,
83+
mimeType,
5384
} = this;
5485
const file = Readable.from([
5586
content,
5687
]);
88+
const drive = this.googleDrive.drive();
5789
const driveId = this.googleDrive.getDriveId(this.drive);
58-
const resp = await this.googleDrive.createFile({
59-
mimeType: "text/plain",
60-
file,
61-
name,
62-
parentId,
63-
driveId,
90+
const parent = parentId ?? driveId;
91+
92+
const { data: resp } = await drive.files.create({
93+
supportsAllDrives: true,
94+
media: {
95+
mimeType,
96+
body: file,
97+
},
98+
requestBody: {
99+
name,
100+
mimeType: "application/vnd.google-apps.document",
101+
parents: [
102+
parent,
103+
],
104+
},
64105
});
106+
65107
$.export("$summary", `Successfully created a new file, "${resp.name}"`);
66108
return resp;
67109
},

components/google_drive/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/google_drive",
3-
"version": "0.8.7",
3+
"version": "0.8.8",
44
"description": "Pipedream Google_drive Components",
55
"main": "google_drive.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)