mirror of
https://github.com/bykof/cordova-plugin-webserver.git
synced 2026-04-20 00:02:45 +08:00
add file responses
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user