-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
53 lines (44 loc) · 1.13 KB
/
index.js
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
'use strict';
const fs = require('fs');
const FormData = require('form-data');
const action = async context => {
const endpoint = 'https://api.streamable.com/upload';
const filePath = await context.filePath();
const form = new FormData();
const credentials = `${context.config.get('username')}:${context.config.get('password')}`;
const authorization = Buffer.from(credentials).toString('base64');
context.setProgress('Uploading…');
form.append('file', fs.createReadStream(filePath));
const response = await context.request(endpoint, {
method: 'post',
body: form,
headers: {authorization: `Basic ${authorization}`}
});
const {shortcode} = JSON.parse(response.body);
context.copyToClipboard(`https://streamable.com/${shortcode}`);
context.notify('URL to the video has been copied to the clipboard');
};
const config = {
username: {
title: 'Username',
type: 'string',
required: true
},
password: {
title: 'Password',
type: 'password',
required: true
}
};
const streamable = {
title: 'Share on Streamable',
formats: [
'gif',
'mp4',
'webm',
'apng'
],
action,
config
};
exports.shareServices = [streamable];