X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=plugins%2Fsamples%2FSamplePost.c;h=88949736def4db45bd759b6d644d4072cde480c1;hb=c1dda27fbbbbbf14aabe5bc8b4cb2a70abfd09f0;hp=13e1ad6742e896b624096b7bae04b69482d87f15;hpb=06d422d1de5c505366f6a029d8af85548c2b646f;p=src%2Fapp-framework-binder.git diff --git a/plugins/samples/SamplePost.c b/plugins/samples/SamplePost.c index 13e1ad67..88949736 100644 --- a/plugins/samples/SamplePost.c +++ b/plugins/samples/SamplePost.c @@ -47,14 +47,10 @@ STATIC json_object* UploadAppli (AFB_request *request, AFB_PostItem *item) { // This is called after PostForm and then after DonePostForm if (item == NULL) { - AFB_PostCtx *postFileCtx = getPostContext(request); - if (postFileCtx != NULL) { - - // Do something intelligent here to install application - - postFileCtx->errcode = MHD_HTTP_OK; // or error is something went wrong; - postFileCtx->jresp = jsonNewMessage(AFB_SUCCESS,"UploadFile Post Appli done"); - } + // Do something intelligent here to install application + request->errcode = MHD_HTTP_OK; // or error is something went wrong; + request->jresp = jsonNewMessage(AFB_SUCCESS,"UploadFile Post Appli=%s done", getPostPath (request)); + // Note: should not return here in order getPostedFile to clear Post resources. } // upload multi iteration logic is handle by getPostedFile @@ -76,17 +72,12 @@ STATIC json_object* UploadImage (AFB_request *request, AFB_PostItem *item) { char *destination = "images"; // This is called after PostForm and then after DonePostForm - if (item == NULL) { - AFB_PostCtx *postFileCtx = getPostContext(request); - - // if postFileCtx == NULL then an error happen [getPostedFile automatically reports errors] - if (postFileCtx != NULL) { - // Do something with your newly upload filepath=postFileCtx->path - request->errcode = MHD_HTTP_OK; - request->jresp = jsonNewMessage(AFB_FAIL,"UploadFile Post Image done"); - - // Note: should not return here in order getPostedFile to clear Post resources. - } + if (item == NULL && getPostPath (request) != NULL) { + // Do something with your newly upload filepath=postFileCtx->path + request->errcode = MHD_HTTP_OK; + request->jresp = jsonNewMessage(AFB_SUCCESS,"UploadFile Post Image done"); + + // Note: should not return here in order getPostedFile to clear Post resources. } // upload multi iteration logic is handle by getPostedFile