@pipedream/slack 0.9.4 → 0.10.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.
- package/actions/upload-file/upload-file.mjs +11 -8
- package/package.json +5 -3
- package/slack.app.mjs +2 -2
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ConfigurationError, axios,
|
|
2
|
+
ConfigurationError, axios, getFileStreamAndMetadata,
|
|
3
3
|
} from "@pipedream/platform";
|
|
4
|
-
import fs from "fs";
|
|
5
4
|
import FormData from "form-data";
|
|
6
5
|
import slack from "../../slack.app.mjs";
|
|
7
6
|
|
|
@@ -9,7 +8,7 @@ export default {
|
|
|
9
8
|
key: "slack-upload-file",
|
|
10
9
|
name: "Upload File",
|
|
11
10
|
description: "Upload a file. [See the documentation](https://api.slack.com/messaging/files#uploading_files)",
|
|
12
|
-
version: "0.0
|
|
11
|
+
version: "0.1.0",
|
|
13
12
|
type: "action",
|
|
14
13
|
props: {
|
|
15
14
|
slack,
|
|
@@ -35,16 +34,16 @@ export default {
|
|
|
35
34
|
},
|
|
36
35
|
},
|
|
37
36
|
async run({ $ }) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
37
|
+
const {
|
|
38
|
+
stream, metadata,
|
|
39
|
+
} = await getFileStreamAndMetadata(this.content);
|
|
41
40
|
|
|
42
41
|
const filename = this.content.split("/").pop();
|
|
43
42
|
|
|
44
43
|
// Get an upload URL from Slack
|
|
45
44
|
const getUploadUrlResponse = await this.slack.getUploadUrl({
|
|
46
45
|
filename,
|
|
47
|
-
length:
|
|
46
|
+
length: metadata.size,
|
|
48
47
|
});
|
|
49
48
|
|
|
50
49
|
if (!getUploadUrlResponse.ok) {
|
|
@@ -57,7 +56,11 @@ export default {
|
|
|
57
56
|
|
|
58
57
|
// Upload the file to the provided URL
|
|
59
58
|
const formData = new FormData();
|
|
60
|
-
formData.append("file",
|
|
59
|
+
formData.append("file", stream, {
|
|
60
|
+
contentType: metadata.contentType,
|
|
61
|
+
knownLength: metadata.size,
|
|
62
|
+
filename: metadata.name,
|
|
63
|
+
});
|
|
61
64
|
formData.append("filename", filename);
|
|
62
65
|
|
|
63
66
|
await axios($, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/slack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Pipedream Slack Components",
|
|
5
5
|
"main": "slack.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@pipedream/platform": "^3.
|
|
18
|
-
"@slack/web-api": "^7.9.0"
|
|
17
|
+
"@pipedream/platform": "^3.1.0",
|
|
18
|
+
"@slack/web-api": "^7.9.0",
|
|
19
|
+
"async-retry": "^1.3.3",
|
|
20
|
+
"lodash": "^4.17.21"
|
|
19
21
|
}
|
|
20
22
|
}
|
package/slack.app.mjs
CHANGED
|
@@ -356,8 +356,8 @@ export default {
|
|
|
356
356
|
},
|
|
357
357
|
},
|
|
358
358
|
content: {
|
|
359
|
-
label: "File Path",
|
|
360
|
-
description: "
|
|
359
|
+
label: "File Path or URL",
|
|
360
|
+
description: "The file to upload. Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.txt`)",
|
|
361
361
|
type: "string",
|
|
362
362
|
},
|
|
363
363
|
link_names: {
|