add file responses

This commit is contained in:
Keith Wait
2018-08-11 21:48:30 -05:00
parent 390a03551c
commit 60f55066ce
4 changed files with 136 additions and 1 deletions
+9
View File
@@ -44,6 +44,10 @@ public class Webserver extends CordovaPlugin {
this.sendResponse(args, callbackContext);
return true;
}
else if ("sendFileResponse".equals(action)) {
this.sendFileResponse(args, callbackContext);
return true;
}
return false; // Returning false results in a "MethodNotFound" error.
}
@@ -96,6 +100,11 @@ public class Webserver extends CordovaPlugin {
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
}
private void sendFileResponse(JSONArray args, CallbackContext callbackContext) throws JSONException {
this.responses.put('file', args.get(1));
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
}
/**
* Just register the onRequest and send no result. This is needed to save the callbackContext to
* invoke it later