-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (38 loc) · 1 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
const fs = require('fs');
const FormData = require('form-data');
const action = async context => {
const endpoint = 'https://uploads.slate.host/api/public';
const filePath = await context.filePath();
context.setProgress('Uploading…');
const form = new FormData();
form.append('data', fs.createReadStream(filePath));
const response = await context.request(endpoint, {
method: 'post',
headers: {
Authorization: context.config.get('apiKey')
},
body: form
});
const data = JSON.parse(response.body).data;
context.copyToClipboard(`https://slate.textile.io/ipfs/${data.cid}`);
context.notify(
`URL to the ${context.prettyFormat} has been copied to the clipboard`
);
};
const config = {
apiKey: {
title: 'API key',
type: 'string',
minLength: 41,
default: '',
required: true
}
};
const slate = {
title: 'Share on Slate',
configDescription: 'Create your API key here: https://slate.host/_/api',
formats: ['gif', 'mp4', 'webm', 'apng'],
action,
config
};
exports.shareServices = [slate];