@pipedream/dropbox 0.4.1 → 1.0.0
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,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import got from "got";
|
|
1
|
+
import { getFileStream } from "@pipedream/platform";
|
|
4
2
|
import consts from "../../common/consts.mjs";
|
|
5
3
|
import dropbox from "../../dropbox.app.mjs";
|
|
6
4
|
|
|
@@ -8,7 +6,7 @@ export default {
|
|
|
8
6
|
name: "Upload a File",
|
|
9
7
|
description: "Uploads a file to a selected folder. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
|
|
10
8
|
key: "dropbox-upload-file",
|
|
11
|
-
version: "0.0
|
|
9
|
+
version: "1.0.0",
|
|
12
10
|
type: "action",
|
|
13
11
|
props: {
|
|
14
12
|
dropbox,
|
|
@@ -27,17 +25,10 @@ export default {
|
|
|
27
25
|
label: "File Name",
|
|
28
26
|
description: "The name of your new file (make sure to include the file extension).",
|
|
29
27
|
},
|
|
30
|
-
fileUrl: {
|
|
31
|
-
type: "string",
|
|
32
|
-
label: "File URL",
|
|
33
|
-
description: "The URL of the file you want to upload to Dropbox. Must specify either File URL or File Path.",
|
|
34
|
-
optional: true,
|
|
35
|
-
},
|
|
36
28
|
filePath: {
|
|
37
29
|
type: "string",
|
|
38
|
-
label: "File Path",
|
|
39
|
-
description: "
|
|
40
|
-
optional: true,
|
|
30
|
+
label: "File Path or URL",
|
|
31
|
+
description: "Provide either a file URL or a path to a file in the /tmp directory (for example, /tmp/myFile.pdf).",
|
|
41
32
|
},
|
|
42
33
|
autorename: {
|
|
43
34
|
type: "boolean",
|
|
@@ -67,7 +58,6 @@ export default {
|
|
|
67
58
|
},
|
|
68
59
|
async run({ $ }) {
|
|
69
60
|
const {
|
|
70
|
-
fileUrl,
|
|
71
61
|
filePath,
|
|
72
62
|
path,
|
|
73
63
|
name,
|
|
@@ -78,13 +68,7 @@ export default {
|
|
|
78
68
|
clientModified,
|
|
79
69
|
} = this;
|
|
80
70
|
|
|
81
|
-
|
|
82
|
-
throw new ConfigurationError("Must specify either File URL or File Path.");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const contents = fileUrl
|
|
86
|
-
? await got.stream(fileUrl)
|
|
87
|
-
: fs.createReadStream(filePath);
|
|
71
|
+
const contents = await getFileStream(filePath);
|
|
88
72
|
|
|
89
73
|
let normalizedPath = this.dropbox.getNormalizedPath(path, true);
|
|
90
74
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
getFileStream, ConfigurationError,
|
|
3
|
+
} from "@pipedream/platform";
|
|
4
4
|
import consts from "../../common/consts.mjs";
|
|
5
5
|
import dropbox from "../../dropbox.app.mjs";
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ export default {
|
|
|
8
8
|
name: "Upload Multiple Files",
|
|
9
9
|
description: "Uploads multiple file to a selected folder. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
|
|
10
10
|
key: "dropbox-upload-multiple-files",
|
|
11
|
-
version: "0.0
|
|
11
|
+
version: "1.0.0",
|
|
12
12
|
type: "action",
|
|
13
13
|
props: {
|
|
14
14
|
dropbox,
|
|
@@ -22,19 +22,10 @@ export default {
|
|
|
22
22
|
],
|
|
23
23
|
description: "The folder to upload to. Type the folder name to search for it in the user's Dropbox.",
|
|
24
24
|
},
|
|
25
|
-
|
|
25
|
+
filesPaths: {
|
|
26
26
|
type: "string[]",
|
|
27
|
-
label: "File URLs",
|
|
28
|
-
description: "
|
|
29
|
-
default: [],
|
|
30
|
-
optional: true,
|
|
31
|
-
},
|
|
32
|
-
filePaths: {
|
|
33
|
-
type: "string[]",
|
|
34
|
-
label: "File Paths",
|
|
35
|
-
description: "The paths to the files, e.g. /tmp/myFile.csv . Must specify either File URLs or File Paths.",
|
|
36
|
-
default: [],
|
|
37
|
-
optional: true,
|
|
27
|
+
label: "File Paths or URLs",
|
|
28
|
+
description: "Provide an array of either file URLs or paths to a files in the /tmp directory (for example, /tmp/myFile.pdf).",
|
|
38
29
|
},
|
|
39
30
|
filenames: {
|
|
40
31
|
type: "string[]",
|
|
@@ -71,8 +62,7 @@ export default {
|
|
|
71
62
|
const {
|
|
72
63
|
dropbox,
|
|
73
64
|
path,
|
|
74
|
-
|
|
75
|
-
filePaths,
|
|
65
|
+
filesPaths,
|
|
76
66
|
autorename,
|
|
77
67
|
mute,
|
|
78
68
|
strictConflict,
|
|
@@ -80,11 +70,7 @@ export default {
|
|
|
80
70
|
filenames,
|
|
81
71
|
} = this;
|
|
82
72
|
|
|
83
|
-
|
|
84
|
-
throw new ConfigurationError("Must specify either File URLs or File Paths.");
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const numFiles = fileUrls.length + filePaths.length;
|
|
73
|
+
const numFiles = filesPaths.length;
|
|
88
74
|
if (numFiles !== filenames.length) {
|
|
89
75
|
throw new ConfigurationError(`Number of filenames must match number of files. Detected ${numFiles} file(s) and ${filenames.length} filename(s)`);
|
|
90
76
|
}
|
|
@@ -93,24 +79,13 @@ export default {
|
|
|
93
79
|
const normalizedPath = dropbox.getNormalizedPath(path, true);
|
|
94
80
|
let i = 0;
|
|
95
81
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (filePaths?.length) {
|
|
107
|
-
for (const filePath of filePaths) {
|
|
108
|
-
fileInfo.push({
|
|
109
|
-
contents: fs.createReadStream(filePath),
|
|
110
|
-
path: `${normalizedPath}${filenames[i]}`,
|
|
111
|
-
});
|
|
112
|
-
i++;
|
|
113
|
-
}
|
|
82
|
+
for (const file of filesPaths) {
|
|
83
|
+
const contents = await getFileStream(file);
|
|
84
|
+
fileInfo.push({
|
|
85
|
+
contents,
|
|
86
|
+
path: `${normalizedPath}${filenames[i]}`,
|
|
87
|
+
});
|
|
88
|
+
i++;
|
|
114
89
|
}
|
|
115
90
|
|
|
116
91
|
const responses = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/dropbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Pipedream Dropbox Components",
|
|
5
5
|
"main": "dropbox.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"homepage": "https://pipedream.com/apps/dropbox",
|
|
11
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
12
12
|
"dependencies": {
|
|
13
|
+
"@pipedream/platform": "^3.1.0",
|
|
13
14
|
"@types/node-fetch": "^2.5.7",
|
|
14
15
|
"dropbox": "^10.34.0",
|
|
15
16
|
"got": "^13.0.0",
|