Skip to content

Commit 8c53e2f

Browse files
committed
Adding selection between file URL or path
1 parent 072e6dc commit 8c53e2f

File tree

3 files changed

+40
-16
lines changed

3 files changed

+40
-16
lines changed

components/google_drive/actions/update-file/update-file.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import {
33
toSingleLineString,
44
getFileStream,
55
} from "../../common/utils.mjs";
6+
import {
7+
additionalProps, useFileUrlOrPath,
8+
} from "../../common/filePathOrUrl.mjs";
69

710
export default {
811
key: "google_drive-update-file",
912
name: "Update File",
1013
description: "Update a file's metadata and/or content. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/update) for more information",
11-
version: "0.1.8",
14+
version: "1.0.0",
1215
type: "action",
16+
additionalProps,
1317
props: {
1418
googleDrive,
15-
requiredPropsAlert: {
16-
type: "alert",
17-
alertType: "info",
18-
content: "Either `File URL` or `File Path` should be specified.",
19-
},
19+
useFileUrlOrPath,
2020
drive: {
2121
propDefinition: [
2222
googleDrive,

components/google_drive/actions/upload-file/upload-file.mjs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,20 @@ import {
55
omitEmptyStringValues,
66
} from "../../common/utils.mjs";
77
import { GOOGLE_DRIVE_UPLOAD_TYPE_MULTIPART } from "../../common/constants.mjs";
8-
import { ConfigurationError } from "@pipedream/platform";
8+
import {
9+
additionalProps, useFileUrlOrPath,
10+
} from "../../common/filePathOrUrl.mjs";
911

1012
export default {
1113
key: "google_drive-upload-file",
1214
name: "Upload File",
1315
description: "Upload a file to Google Drive. [See the documentation](https://developers.google.com/drive/api/v3/manage-uploads) for more information",
14-
version: "0.1.11",
16+
version: "1.0.0",
1517
type: "action",
18+
additionalProps,
1619
props: {
1720
googleDrive,
18-
infoAlert: {
19-
type: "alert",
20-
alertType: "info",
21-
content: "Either `File URL` or `File Path` should be specified.",
22-
},
21+
useFileUrlOrPath,
2322
drive: {
2423
propDefinition: [
2524
googleDrive,
@@ -44,12 +43,16 @@ export default {
4443
googleDrive,
4544
"fileUrl",
4645
],
46+
optional: false,
47+
hidden: true,
4748
},
4849
filePath: {
4950
propDefinition: [
5051
googleDrive,
5152
"filePath",
5253
],
54+
optional: false,
55+
hidden: true,
5356
},
5457
name: {
5558
propDefinition: [
@@ -94,9 +97,6 @@ export default {
9497
mimeType,
9598
} = this;
9699
let { uploadType } = this;
97-
if (!fileUrl && !filePath) {
98-
throw new ConfigurationError("Either `File URL` or `File Path` should be specified.");
99-
}
100100
const driveId = this.googleDrive.getDriveId(this.drive);
101101

102102
const filename = name || path.basename(fileUrl || filePath);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const useFileUrlOrPath = {
2+
type: "string",
3+
label: "Use File URL or File Path",
4+
description: "Whether to upload a file from a URL or from the `/tmp` folder",
5+
options: [
6+
"File URL",
7+
"File Path",
8+
],
9+
reloadProps: true,
10+
};
11+
12+
export async function additionalProps(previousProps) {
13+
const { useFileUrlOrPath } = this;
14+
15+
if (useFileUrlOrPath === "File URL") {
16+
previousProps.fileUrl.hidden = false;
17+
previousProps.filePath.hidden = true;
18+
} else if (useFileUrlOrPath === "File Path") {
19+
previousProps.fileUrl.hidden = true;
20+
previousProps.filePath.hidden = false;
21+
}
22+
23+
return {};
24+
}

0 commit comments

Comments
 (0)