|
| 1 | +# Filetracker server API |
| 2 | + |
| 3 | +Filetracker server (starting from version 2.0) provides a simple HTTP API for |
| 4 | +clients. Filetracker client is the primary consumer of this API, but its simplicity |
| 5 | +allows to interact with the server using plain `curl` or Python `requests`. |
| 6 | + |
| 7 | +## API reference |
| 8 | + |
| 9 | +### `GET /files/{path}` |
| 10 | + |
| 11 | +Retrieves a file from the server saved under `{path}`. `{path}` should |
| 12 | +be a `/`-delimited sequence of alphanumeric words. |
| 13 | + |
| 14 | +If the file doesn't exist, response will have status code 404. |
| 15 | + |
| 16 | +May return the stream gzip-compressed, setting the appropriate |
| 17 | +`Content-Encoding: gzip` header. |
| 18 | + |
| 19 | +Will set `Logical-Size` header to the logical size of the file, which is |
| 20 | +the size after decompression if `Content-Encoding: gzip` is set. |
| 21 | + |
| 22 | +Will set `Last-Modified` header to the file modification time ("version") |
| 23 | +in RFC 2822 format. |
| 24 | + |
| 25 | +### `HEAD /files/{path}` |
| 26 | + |
| 27 | +Behaves the same as `GET`, but doesn't include the response body. |
| 28 | + |
| 29 | +_CAUTION: some server implementations (notably migration server) may |
| 30 | +respond with 307 Temporary Redirect to HEAD requests. You should make sure |
| 31 | +to follow it, since this is not the default behavior in some HTTP clients._ |
| 32 | + |
| 33 | +### `PUT /files/{path}` |
| 34 | + |
| 35 | +Uploads a file to to the server saving it under `{path}`. |
| 36 | + |
| 37 | +File version must be specified in RFC 2822 format through |
| 38 | +`?last_modified=` query parameter. If the server has older file version, |
| 39 | +it will be overwritten. If the server has newer version, the operation will |
| 40 | +have no effect. |
| 41 | + |
| 42 | +If the operation is successful, the response will have `Last-Modified` |
| 43 | +header set to the version of the file under `{path}` on the server |
| 44 | +after processing the request. |
| 45 | + |
| 46 | +Payload should be compressed with gzip, and `Content-Encoding: gzip` |
| 47 | +header must be set if it is. |
| 48 | + |
| 49 | +`SHA256-Checksum` header should be set to hexadecimal representation |
| 50 | +of SHA256 digest of file _before compression_. |
| 51 | + |
| 52 | +`Logical-Size` header should be set to logical file size in bytes |
| 53 | +(before compression). |
| 54 | + |
| 55 | +_NOTE: three headers above related to compression are optional, but |
| 56 | +performance may suffer if any of them is not set, so this should be only |
| 57 | +used while testing._ |
| 58 | + |
| 59 | +### `DELETE /files/{path}` |
| 60 | + |
| 61 | +Deletes a file saved under `{path}` from the server. |
| 62 | + |
| 63 | +File version must be specified in RFC 2822 format through |
| 64 | +`?last_modified=` query parameter. If the server has older file version, |
| 65 | +the file will be deleted. If the server has newer file version, the operation |
| 66 | +will have no effect. |
| 67 | + |
| 68 | +If the file doesn't exist, response will have status code 404. |
| 69 | + |
| 70 | +### Concurrency guarantees for the operations above |
| 71 | + |
| 72 | +All single-file operations described above are guaranteed to be |
| 73 | +safe to perform concurrently. |
| 74 | + |
| 75 | +Concurrent modifying operations on the same file may be performed in |
| 76 | +non-deterministic order, but it's guaranteed that no more that one |
| 77 | +modifying operation is performed on the same file at any point in time. |
| 78 | + |
| 79 | +### `GET /list/{path}` |
| 80 | + |
| 81 | +Retrieves a list of paths to all files saved under a directory |
| 82 | +(in the usual Unix sense), in no particular order, recursively visiting |
| 83 | +subdirectories. |
| 84 | + |
| 85 | +The returned file paths are relative to `{path}` and do not contain leading |
| 86 | +slashes. |
| 87 | + |
| 88 | +The response is plain-text, with one line for every file path. |
| 89 | + |
| 90 | +Version cutoff must be specified in RFC 2822 format through |
| 91 | +`?last_modified=` query parameter. Only files with modification time |
| 92 | +older than this version will be listed. |
| 93 | + |
| 94 | +If `Accepts` request header is set, the response format may be different. |
| 95 | + |
| 96 | +__CAUTION:__ this operation is only guaranteed to return consistent |
| 97 | +results in concurrent scenarios if no modifications took place while it's |
| 98 | +running that would affect whether some file would appear on the list. |
0 commit comments