X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=plugins%2Fsamples%2FSamplePost.c;h=13e1ad6742e896b624096b7bae04b69482d87f15;hb=7181ede7add4eb3f5a92f5f8c9fd9cc8fdf6c659;hp=56c3f24b22a773f3d80c16d5489bdf4f1d7068cd;hpb=5472e85501418302959040eacb819c57f849d63e;p=src%2Fapp-framework-binder.git diff --git a/plugins/samples/SamplePost.c b/plugins/samples/SamplePost.c index 56c3f24b..13e1ad67 100644 --- a/plugins/samples/SamplePost.c +++ b/plugins/samples/SamplePost.c @@ -50,10 +50,10 @@ STATIC json_object* UploadAppli (AFB_request *request, AFB_PostItem *item) { AFB_PostCtx *postFileCtx = getPostContext(request); if (postFileCtx != NULL) { - // request Application Framework to install application + // Do something intelligent here to install application - request->errcode = MHD_HTTP_OK; // or error is something went wrong; - request->jresp = jsonNewMessage(AFB_FAIL,"UploadFile Post Request file=[%s] done", postFileCtx->path); + postFileCtx->errcode = MHD_HTTP_OK; // or error is something went wrong; + postFileCtx->jresp = jsonNewMessage(AFB_SUCCESS,"UploadFile Post Appli done"); } } @@ -64,10 +64,8 @@ STATIC json_object* UploadAppli (AFB_request *request, AFB_PostItem *item) { // Simples Upload case just upload a file STATIC json_object* UploadMusic (AFB_request *request, AFB_PostItem *item) { - char *destination = "musics"; - // upload multi iteration logic is handle by getPostedFile - return (getPostFile (request, item, destination)); + return (getPostFile (request, item, "musics")); } // PostForm callback is called multiple times (one or each key within form, or once per file buffer) @@ -85,7 +83,7 @@ STATIC json_object* UploadImage (AFB_request *request, AFB_PostItem *item) { if (postFileCtx != NULL) { // Do something with your newly upload filepath=postFileCtx->path request->errcode = MHD_HTTP_OK; - request->jresp = jsonNewMessage(AFB_FAIL,"UploadFile Post Request file=[%s] done", postFileCtx->path); + request->jresp = jsonNewMessage(AFB_FAIL,"UploadFile Post Image done"); // Note: should not return here in order getPostedFile to clear Post resources. } @@ -110,7 +108,7 @@ STATIC AFB_restapi pluginApis[]= { PUBLIC AFB_plugin *pluginRegister () { AFB_plugin *plugin = malloc (sizeof (AFB_plugin)); plugin->type = AFB_PLUGIN_JSON; - plugin->info = "Application Framework Binder Service"; + plugin->info = "Sample with Post Upload Files"; plugin->prefix= "post"; // url base plugin->apis = pluginApis; plugin->handle= (void*) "What ever you want";