Description
Currently a write to the VFS has nested methods and argument:
{ method: "fs",
arguments: {
method: "write",
arguments: ["home:///text.txt", "data:text/plain;base64,cnJnaGk=", {}]
}
}
The URL is http://osjsv2.0o.no/API
My suggestion is to change that url to http://osjsv2.0o.no/FS/write and the following payload:
{
path: "home:///text.txt",
mime: "text/plain",
options: {},
encoding: "Base64",
data: "cnJnaGk="
}
On the backend a MVC/WebAPI/REST style can be used.
FS would be the controller and write the action. The body would then have a very simple payload with meaningful properties that does not need any parsing.
It is also more in line with for instance what the scandir function returns.
Also adding a option 'overwrite' as mentioned in my other issue would be nice to have to make sure the backend has permission to overwrite a file. Other options could be 'append','touch' and maybe others.
I can get this by changing my custom handler by parsing the object before sending it, but i think it would be nice for others also.
Here is a snippet of my handler that changes the url and content.
//Map to a controller and action
switch (method) {
case "login":
case "logout":
case "settings":
path = APIURI;
controller = "/auth/";
action = method;
break;
case "fs":
path = FSURI;
controller = '';
action = args.method;
break;
}
var data = {
url: path + controller + action,
method: 'POST',
json: true,
body: {
'arguments': args.arguments
},
This is without parsing the arguments as i think that would be much better if done before it gets to this function.