From 02a053a4b815ad367ce0d5b8c6b58598251ca455 Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Sun, 23 Feb 2014 10:17:05 -0800 Subject: [PATCH] feat(Documentation/api): document file upload This gets asked about a lot int IRC/mailinglist/etc. Fixes this issue: https://github.com/coreos/etcd/issues/383#issuecomment-31183603 --- Documentation/api.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Documentation/api.md b/Documentation/api.md index a52d7f652..19aa96ff2 100644 --- a/Documentation/api.md +++ b/Documentation/api.md @@ -783,6 +783,28 @@ curl -L http://127.0.0.1:4001/v2/keys/ Here we see the `/message` key but our hidden `/_message` key is not returned. +### Setting a key from a file + +You can also use etcd to store small configuration files, json documents, XML documents, etc directly. +For example you can use curl to upload a simple text file and encode it: + +``` +echo "Hello\nWorld" > afile.txt +curl -L http://127.0.0.1:4001/v2/keys/afile -XPUT --data-urlencode value@afile.txt +``` + +```json +{ + "action": "get", + "node": { + "createdIndex": 2, + "key": "/afile", + "modifiedIndex": 2, + "value": "Hello\nWorld\n" + } +} +``` + ### Read Consistency Followers in a cluster can be behind the leader in their copy of the keyspace.