aboutsummaryrefslogtreecommitdiffstats
path: root/pomf-standard.txt
blob: 8f5588d1a916cccf6afa8e29f467e2623bb1dce5 (plain)
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
Upload API endpoint:
	/upload.php


POST arguments:
	files[]: 
		Content-Type: multipart/form-data
		File to upload; multiple values supported.


GET arguments:
	output:
		The output format to use. If not specified, defaults to 'json'.

		gyazo:
			Content-Type: text/plain
			Complete URLs to uploaded files in the same order as the input files, separated by newlines. Does not have a trailing newline (Pomf1 compat version).
			Example output: 'https://example.com/foobar.jpg\nhttps://example.com/qweasd.txt'

		text:
			Content-Type: text/plain
			Complete URLs to uploaded files in the same order as input files. Each line ends in a newline (Unix style).
			Example output: 'https://example.com/foobar.jpg\nhttps://example.com/qweasd.txt\n'

		html:
			Content-Type: text/html
			A HTML page containing links to uploaded files. Can be anything and is primarily meant to be shown to a human user.
			Example output: '<a href="https://example.com/foobar.jpg">https://example.com/foobar.jpg</a><br /><a href="https://example.com/qweasd.txt">https://example.com/qweasd.txt</a><br />'

		json:
			Content-Type: application/json
			Schema:
				{
					"success": bool /* true if everything is okay, false if there was an error */,
					"errorcode": int /* only if success=false, the HTTP error code */,
					"description": string /* only if success=false, the error message */,
					"files": [
						{
							"name": string /* original filename sent by the client */,
							"url": string /* the complete URL to the uploaded file */,
							"hash": string /* the SHA-1 hash of the uploaded file */,
							"size": int /* the bytesize of the uploaded file */
						}
					] /* only if success=true, info about uploaded files in the same order they were uploaded */
				}
			Clients *must not* assume a specific ordering of keys in objects nor any presence/absence of whitespace (outside strings); regex is not a good way to parse this.
			Example output: '{"success": true, "files": [{"name": "cat.jpg", "url": "https://example.com/foobar.jpg", "hash": "8d26e24aabb26c02b5c9a9e102308af2a3597a49", "size": 44294}, {"name": "file.txt", "url": "https://example.com/qweasd.txt", "hash": "da39a3ee5e6b4b0d3255bfef95601890afd80709", "size": 0}]}'

		csv:
			Content-Type: text/csv
			A CSV document listing the name, url, hash and size of uploaded files (same meanings as in the JSON response).
			Dialect: delimiter=',', quotechar='"'
			Headers are written on the first line.
			Example output: 'name,url,hash,size\ncat.jpg,https://example.com/foobar.jpg,8d26e24aabb26c02b5c9a9e102308af2a3597a49,44294\nfile.txt,https://example.com/qweasd.txt,da39a3ee5e6b4b0d3255bfef95601890afd80709,0\n'


Rationale:
	Such an API would provide the maximum compatibility with Pomf1 and Pomf2 while still implementing all the important features.