aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-05-13 11:50:38 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-05-13 11:52:35 +0200
commit09b02c50df8ae0d87ce7b3e5e092eb93086f5f1e (patch)
tree1bdafd20719928b2e30cf0ab382f574fed22971d
parentaacefae70dd8c6b21398fa7a60574a24e1287eb0 (diff)
implements the example for file uploading
Change-Id: I3171edbb702eecde401a218f8a56cc365aeaadbb Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--plugins/samples/SamplePost.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/plugins/samples/SamplePost.c b/plugins/samples/SamplePost.c
index d6c5dec8..cfb0c591 100644
--- a/plugins/samples/SamplePost.c
+++ b/plugins/samples/SamplePost.c
@@ -47,7 +47,11 @@ static void GetJsonByPost (struct afb_req request)
// Upload a file and execute a function when upload is done
static void Uploads (struct afb_req request, const char *destination)
{
- afb_req_fail_f(request, "unimplemented", "destination: %s", destination);
+ struct afb_arg a = afb_req_get(request, "file");
+ if (a.value == NULL || *a.value == 0)
+ afb_req_fail_f(request, "failed", "no file selected");
+ else
+ afb_req_success_f(request, NULL, "uploaded file %s of path %s for destination %s", a.value, a.path, destination);
}
// Upload a file and execute a function when upload is done