@pipedream/google_drive 0.6.14 → 0.6.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ export default {
|
|
10
10
|
key: "google_drive-upload-file",
|
11
11
|
name: "Upload File",
|
12
12
|
description: "Copy an existing file to Google Drive. [See the docs](https://developers.google.com/drive/api/v3/manage-uploads) for more information",
|
13
|
-
version: "0.1.
|
13
|
+
version: "0.1.3",
|
14
14
|
type: "action",
|
15
15
|
props: {
|
16
16
|
googleDrive,
|
@@ -69,26 +69,14 @@ export default {
|
|
69
69
|
default: GOOGLE_DRIVE_UPLOAD_TYPE_MULTIPART,
|
70
70
|
optional: true,
|
71
71
|
},
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
fileId: {
|
73
|
+
propDefinition: [
|
74
|
+
googleDrive,
|
75
|
+
"fileId",
|
76
|
+
],
|
77
|
+
label: "File to replace",
|
78
|
+
description: "Id of the file to replace. Leave it empty to upload a new file.",
|
76
79
|
optional: true,
|
77
|
-
default: false,
|
78
|
-
},
|
79
|
-
},
|
80
|
-
methods: {
|
81
|
-
async getFileIdForReplace(filename, parentId) {
|
82
|
-
if (this.replaceFile) {
|
83
|
-
const { files } = await this.googleDrive.listFilesInPage(null, {
|
84
|
-
q: `name = '${filename}' and '${parentId || "root"}' in parents and trashed = false`,
|
85
|
-
fields: "files/id,files/name,files/parents",
|
86
|
-
});
|
87
|
-
if (files.length) {
|
88
|
-
return files[0].id;
|
89
|
-
}
|
90
|
-
}
|
91
|
-
return null;
|
92
80
|
},
|
93
81
|
},
|
94
82
|
async run({ $ }) {
|
@@ -106,7 +94,6 @@ export default {
|
|
106
94
|
const driveId = this.googleDrive.getDriveId(this.drive);
|
107
95
|
|
108
96
|
const filename = name || path.basename(fileUrl || filePath);
|
109
|
-
const fileId = await this.getFileIdForReplace(filename, parentId);
|
110
97
|
|
111
98
|
const file = await getFileStream({
|
112
99
|
$,
|
@@ -116,12 +103,12 @@ export default {
|
|
116
103
|
console.log(`Upload type: ${uploadType}.`);
|
117
104
|
|
118
105
|
let result = null;
|
119
|
-
if (fileId) {
|
120
|
-
await this.googleDrive.updateFileMedia(fileId, file, omitEmptyStringValues({
|
106
|
+
if (this.fileId) {
|
107
|
+
await this.googleDrive.updateFileMedia(this.fileId, file, omitEmptyStringValues({
|
121
108
|
mimeType,
|
122
109
|
uploadType,
|
123
110
|
}));
|
124
|
-
result = await this.googleDrive.updateFile(fileId, omitEmptyStringValues({
|
111
|
+
result = await this.googleDrive.updateFile(this.fileId, omitEmptyStringValues({
|
125
112
|
name: filename,
|
126
113
|
mimeType,
|
127
114
|
uploadType,
|