Skip to content

Commit acbc51c

Browse files
timabelltomasz1986acolomb
authored
chore(rest): explain more clearly how to use /rest/db/file (#817)
This adds an example curl call and explains the parameters more clearly. Co-authored-by: tomasz1986 <[email protected]> Co-authored-by: André Colomb <[email protected]>
1 parent 724512c commit acbc51c

File tree

1 file changed

+57
-36
lines changed

1 file changed

+57
-36
lines changed

rest/db-file-get.rst

Lines changed: 57 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,31 @@
11
GET /rest/db/file
22
=================
33

4-
Returns most data available about a given file, including version and
5-
availability. Takes ``folder`` and ``file`` parameters. ``local`` and
6-
``global`` refer to the current file on disk and the globally newest file,
7-
respectively.
4+
Returns most data about a given file, including version and availability.
85

9-
.. code-block::
6+
Request
7+
-------
8+
9+
The call requires parameters for ``folder`` and ``file`` in the query string:
10+
11+
- ``folder`` is the folder ID which you can find in the Syncthing Web GUI,
12+
e.g. ``5camp-slpa8``.
13+
14+
- ``file`` is the relative path of the file starting from the folder root to the
15+
file you are interested in. The path and filename must be correctly
16+
URL-encoded.
17+
18+
Example Request
19+
^^^^^^^^^^^^^^^
20+
21+
.. code-block:: bash
22+
23+
$ curl -s -H X-API-KEY:... "http://localhost:8384/rest/db/file?folder=YOUR_FOLDER_ID" --url-query "file=path/to/file.pdf"
24+
25+
Response
26+
--------
27+
28+
.. code-block:: json
1029
1130
{
1231
"availability": [
@@ -16,46 +35,48 @@ respectively.
1635
}
1736
],
1837
"global": { /* a file entry */ },
19-
"local": { /* a file entry */ }
20-
}
21-
22-
A file entry looks like this::
23-
24-
{
25-
{
26-
"deleted": false,
27-
"ignored": false,
28-
"inodeChange": "1970-01-01T01:00:00+01:00",
29-
"invalid": false,
30-
"localFlags": 0,
31-
"modified": "2022-09-28T08:07:19.979723+02:00",
32-
"modifiedBy": "523ITIE",
33-
"mustRescan": false,
34-
"name": "img",
35-
"noPermissions": false,
36-
"numBlocks": 0,
37-
"permissions": "0755",
38-
"platform": { /* platform specific data */ },
39-
"sequence": 914,
40-
"size": 128,
41-
"type": "FILE_INFO_TYPE_DIRECTORY",
42-
"version": [
43-
"523ITIE:1664345275"
44-
]
45-
},
38+
"local": { /* a file entry */ },
4639
"mtime": {
4740
"err": null,
4841
"value": {
4942
"real": "0001-01-01T00:00:00Z",
5043
"virtual": "0001-01-01T00:00:00Z"
51-
}
5244
}
5345
}
5446
47+
``local`` and ``global`` refer to the current file on the local device and the
48+
globally newest file, respectively. A file entry looks like this:
49+
50+
.. code-block:: json
51+
52+
{
53+
"deleted": false,
54+
"ignored": false,
55+
"inodeChange": "1970-01-01T01:00:00+01:00",
56+
"invalid": false,
57+
"localFlags": 0,
58+
"modified": "2022-09-28T08:07:19.979723+02:00",
59+
"modifiedBy": "523ITIE",
60+
"mustRescan": false,
61+
"name": "img",
62+
"noPermissions": false,
63+
"numBlocks": 0,
64+
"permissions": "0755",
65+
"platform": { /* platform specific data */ },
66+
"sequence": 914,
67+
"size": 128,
68+
"type": "FILE_INFO_TYPE_DIRECTORY",
69+
"version": [
70+
"523ITIE:1664345275"
71+
]
72+
}
73+
5574
Platform specific data may be ownership, extended attributes, etc. and is
56-
divided into entries per operating system / platform. An example platform
57-
entry containing ownership information for Unix systems and an extended
58-
attribute for macOS ("darwin") looks as follows::
75+
divided into entries per operating system / platform. An example platform entry
76+
containing ownership information for Unix systems and an extended attribute for
77+
macOS ("darwin") looks as follows:
78+
79+
.. code-block:: json
5980
6081
{
6182
"darwin": {

0 commit comments

Comments
 (0)