-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathupload-media.mjs
82 lines (79 loc) · 1.71 KB
/
upload-media.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import app from "../../speak_ai.app.mjs";
export default {
key: "speak_ai-upload-media",
name: "Upload Media",
description: "Upload an audio or video file for transcription and natural language processing into Speak AI. [See the documentation](https://docs.speakai.co/#c6106a66-6a3d-4b05-b4a2-4a68a4c1e95d).",
version: "0.0.1",
type: "action",
props: {
app,
name: {
type: "string",
label: "Name",
description: "Name of the media file",
},
url: {
type: "string",
label: "URL",
description: "Public URL or AWS signed URL",
},
mediaType: {
propDefinition: [
app,
"mediaType",
],
},
folderId: {
propDefinition: [
app,
"folderId",
],
},
description: {
type: "string",
label: "Description",
description: "Description of the media file",
optional: true,
},
tags: {
type: "string[]",
label: "Tags",
description: "Optional metadata tags for the media file upload",
optional: true,
},
},
methods: {
uploadMedia(args = {}) {
return this.app.post({
path: "/media/upload",
...args,
});
},
},
async run({ $ }) {
const {
uploadMedia,
name,
url,
mediaType,
folderId,
description,
tags,
} = this;
const response = await uploadMedia({
$,
data: {
name,
url,
mediaType,
folderId,
description,
tags: Array.isArray(tags)
? tags.join(",")
: tags,
},
});
$.export("$summary", `Successfully uploaded media with ID \`${response.data.mediaId}\`.`);
return response;
},
};