Command line / files
files
tinystore files puts, gets, lists and deletes a store's files from a shell,
with no SDK. put and delete write through the server that holds the
directory, or start one. get and list read beside the program or server
that holds the directory.
tinystore files ./data put avatars users/42/avatar.png ./avatar.png
tinystore files ./data get avatars users/42/avatar.png ./avatar.png
tinystore files ./data list avatars users/42/
tinystore files ./data delete avatars users/42/avatar.pngPut a file
tinystore files ./data put avatars users/42/avatar.png ./avatar.png
pg_dump app | tinystore files ./data put dumps app.sql -put users/42/avatar.png in files avatars, 12.4 KiB image/png- The words are the set, the file's path in it, and the local file.
-reads the bytes from stdin. - It replaces whatever the path held, so the same command sent again leaves the same file.
--type image/pnggives the content type. Without it, a common extension gives one,.png,.jpg,.json,.txt,.htmland a few more, and any other file is bytes,application/octet-stream.- A file of any size goes: one past 2 MiB is sent in pieces.
Get a file
tinystore files ./data get avatars users/42/avatar.png ./avatar.pngwrote ./avatar.png, 12.4 KiB- It writes to the path it is given, never to stdout, since PowerShell's
>writes a program's bytes back as text. - A file already at the path is refused unless
--force. - It writes beside the path and renames once the file is whole, and the bytes are checked against their SHA-256 as they are read, so a failure leaves no half-written file.
List a set
tinystore files ./data list avatars
tinystore files ./data list avatars users/42/users/42/avatar.png 12.4 KiB 26 Oct 14:32:07 image/png
users/43/avatar.png 9.1 KiB 26 Oct 14:35:51 image/png- A second word lists the paths that start with it.
--limitsets how many a page holds, 100 when not given. When there are more, stderr says what--afterreads on.--jsongives a line per file, with its size, ETag, type and times whole and UTC, and a last line{"next": "…"}when there are more.
Delete a file
tinystore files ./data delete avatars users/42/avatar.pngdeleted users/42/avatar.png from files avatarsA path that holds no file says files avatars holds no users/42/avatar.png
and exits 0.
Who writes
put and delete write as every write of the command line does: through
tinystore serve or an SDK's sidecar when one holds the directory, or a
sidecar they start, which stops 30 seconds after its last client. A directory
that a program opened embedded is refused, since no other process can write
to it. See metrics: who writes.
See also
- blobs: files from a program, uploads, conditions and expiry.