3 |
4 |
Direct Upload API
5 |
6 |
tiny[stash] Direct Upload API allows you to upload files using various HTTP libraries for programming languages or HTTP clients such as curl.
7 |
8 |
9 |
10 |
Examples
11 |
12 |
13 | curl {* link_url_prefix *}/upload/file -H App-ID:example -H Content-Type:video/mp4 --data-binary @/path/to/video.mp4
14 |
15 |
16 | echo 'This is my first text upload' | curl {* link_url_prefix *}/upload/text -H App-ID:example -H Accept:application/json --data-binary @-
17 |
18 |
19 | curl {* link_url_prefix *}/upload/url -H App-ID:example -d url=https://www.gnu.org/graphics/gnu-head.png
20 |
21 |
Endpoints
22 |
23 |
24 | - File uploads:
{* link_url_prefix *}/upload/file
25 | - Text uploads:
{* link_url_prefix *}/upload/text
26 | - URL uploads:
{* link_url_prefix *}/upload/url
27 |
28 |
29 |
30 |
31 |
Common Headers
32 |
33 |
The following headers are used by all endpoints.
34 |
35 |
36 | App-ID Required. An arbitrary string.
37 | Accept Optional. Set to application/json to get a JSON response (plain text will be used otherwise).
38 |
39 |
40 |
41 |
42 |
File Upload
43 |
44 |
Endpoint
45 |
46 |
{* link_url_prefix *}/upload/file
47 |
48 |
Headers
49 |
50 |
51 | Content-Length Required. The size of a body in bytes. {( includes/max_file_size.txt )}
52 | Content-Type Optional. The default value is application/octet-stream.
53 |
54 |
55 |
Body
56 |
57 |
Raw file content. Compressed or chunked transfer encodings are not supported.
58 |
59 |
60 |
61 |
Text Upload
62 |
63 |
Endpoint
64 |
65 |
{* link_url_prefix *}/upload/text
66 |
67 |
Headers
68 |
69 |
70 | Content-Length Required. The size of a body in bytes. {( includes/max_file_size.txt )}
71 |
72 |
73 |
Body
74 |
75 |
Text content. Compressed or chunked transfer encodings are not supported.
76 |
77 |
78 |
79 |
URL Upload
80 |
81 |
Endpoint
82 |
83 |
{* link_url_prefix *}/upload/url
84 |
85 |
Headers
86 |
87 |
88 | Content-Type Required. One of:
89 |
90 | application/json
91 | application/x-www-form-urlencoded
92 | text/plain
93 |
94 |
95 |
96 |
Body
97 |
98 |
99 | - JSON:
{"url": "<URL>"}
100 | - URL-encoded form:
url=<URL>
101 | - Plain text:
<URL>
102 |
103 |
104 |
{( includes/max_file_size.txt )}
105 |
106 |
107 |
--------------------------------------------------------------------------------
/commands/webhook.lua:
--------------------------------------------------------------------------------
1 | local http = require('resty.http')
2 | local json = require('cjson.safe')
3 |
4 | local config = require('app.config')
5 | local token = config.tg.token
6 | local secret = config._processed.tg_webhook_secret
7 |
8 |
9 | local assume_yes = false
10 | local verbose = false
11 |
12 | if not token then
13 | error('Bad config: set tg.token')
14 | end
15 |
16 | local verbose_print = function(...)
17 | if verbose then
18 | print(...)
19 | end
20 | end
21 |
22 | local show_help = function()
23 | print([[Usage:
24 | webhook get get current webhook status
25 | webhook set set webhook to