@pipedream/google_drive 0.4.8 → 0.4.9
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.
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import googleDrive from "../../google_drive.app.mjs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import {
|
|
4
|
-
getFileStream,
|
|
5
|
-
streamToBuffer,
|
|
6
|
-
byteToMB,
|
|
7
|
-
} from "../../utils.mjs";
|
|
3
|
+
import { getFileStream } from "../../utils.mjs";
|
|
8
4
|
import { omitEmptyStringValues } from "../../utils.mjs";
|
|
9
|
-
import {
|
|
10
|
-
GOOGLE_DRIVE_UPLOAD_TYPE_MEDIA,
|
|
11
|
-
GOOGLE_DRIVE_UPLOAD_TYPE_RESUMABLE,
|
|
12
|
-
} from "../../constants.mjs";
|
|
5
|
+
import { GOOGLE_DRIVE_UPLOAD_TYPE_MULTIPART } from "../../constants.mjs";
|
|
13
6
|
|
|
14
7
|
export default {
|
|
15
8
|
key: "google_drive-upload-file",
|
|
16
9
|
name: "Upload File",
|
|
17
10
|
description: "Copy an existing file to Google Drive. [See the docs](https://developers.google.com/drive/api/v3/manage-uploads) for more information",
|
|
18
|
-
version: "0.0.
|
|
11
|
+
version: "0.0.7",
|
|
19
12
|
type: "action",
|
|
20
13
|
props: {
|
|
21
14
|
googleDrive,
|
|
@@ -71,6 +64,7 @@ export default {
|
|
|
71
64
|
googleDrive,
|
|
72
65
|
"uploadType",
|
|
73
66
|
],
|
|
67
|
+
default: GOOGLE_DRIVE_UPLOAD_TYPE_MULTIPART,
|
|
74
68
|
optional: true,
|
|
75
69
|
},
|
|
76
70
|
},
|
|
@@ -92,20 +86,7 @@ export default {
|
|
|
92
86
|
fileUrl,
|
|
93
87
|
filePath,
|
|
94
88
|
});
|
|
95
|
-
|
|
96
|
-
try {
|
|
97
|
-
const fileBuffer = await streamToBuffer(file);
|
|
98
|
-
const bufferSize = byteToMB(Buffer.byteLength(fileBuffer));
|
|
99
|
-
uploadType = bufferSize > 5
|
|
100
|
-
? GOOGLE_DRIVE_UPLOAD_TYPE_RESUMABLE
|
|
101
|
-
: GOOGLE_DRIVE_UPLOAD_TYPE_MEDIA;
|
|
102
|
-
console.log(`Upload type: ${uploadType}`);
|
|
103
|
-
} catch (err) {
|
|
104
|
-
console.log(err);
|
|
105
|
-
uploadType = "media";
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
console.log(`Upload type: ${uploadType}`);
|
|
89
|
+
console.log(`Upload type: ${uploadType}.`);
|
|
109
90
|
const resp = await this.googleDrive.createFile(omitEmptyStringValues({
|
|
110
91
|
file,
|
|
111
92
|
mimeType,
|