-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
67 lines (59 loc) · 1.44 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'use strict';
const fs = require('fs');
const request = require('request');
const contentTypes = new Map([
['.gif', 'image/gif'],
['.mp4', 'video/mp4'],
['.webm', 'video/webm'],
['.apng', 'image/apng']
]);
const action = async context => {
const filePath = await context.filePath();
context.setProgress('Uploading…');
const formData = {
image: fs.createReadStream(filePath)
};
// const options = {
// hostname: context.config.get('host'),
// port: context.config.get('port'),
// path: context.config.get('path'),
// method: context.config.get('method')
// }
var upload = request.post({url:'https://i.cwlf.uk', formData: formData}, function(error, response, data) {
let uploadURL = data;
context.copyToClipboard(uploadURL);
context.notify('URL copied to the clipboard');
})
};
const http = {
title: 'Send HTTP(S) request',
formats: ['gif', 'mp4', 'webm', 'apng'],
action,
config: {
// host: {
// title: 'Hostname',
// type: 'string',
// default: 'i.cwlf.uk',
// required: true
// },
// port: {
// title: 'Port',
// type: 'string',
// default: '443',
// required: false
// },
// path: {
// title: 'Path',
// type: 'string',
// default: '/',
// required: false
// },
// method: {
// title: 'HTTP Method',
// type: 'string',
// default: 'POST',
// required: false
// }
}
};
exports.shareServices = [http];