provides developper files
[src/app-framework-binder.git] / plugins / samples / SamplePost.c
index 6def3b9..1d3069e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 "IoT.bzh"
+ * Copyright (C) 2015, 2016 "IoT.bzh"
  * Author "Fulup Ar Foll"
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
 #define _GNU_SOURCE
 #include <stdio.h>
 #include <string.h>
-#include <json.h>
+#include <json-c/json.h>
 
-#include "afb-plugin.h"
-#include "afb-req-itf.h"
+#include <afb/afb-plugin.h>
 
 
 // Sample Generic Ping Debug API
@@ -48,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(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