// This is called after PostForm and then after DonePostForm
if (item == NULL) {
- AFB_PostCtx *postFileCtx = getPostContext(request);
- if (postFileCtx != NULL) {
-
- // request Application Framework 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);
- }
+ // 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
// 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)
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 Request file=[%s] done", postFileCtx->path);
-
- // 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
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";