How do you upload files using the RestWS module? I have a remote front-end application under development and I would like to interface with Drupal as a backend service, using the RestWS module to create a RESTful service to my Drupal instance (using JSON as my data format).

I have a node content type of type "article", that has an image field on it called "field_image".

I'm currently trying to figure out the proper way to upload a file to Drupal through the API created by RestWS.

I can retrieve a node with a file attachment via GET to the URL http://www.example.com/node/1.json, which retrieves the contents of node 1, including the information about the uploaded file:

https://gist.github.com/lhridley/8bbf95294aa529d74c74

I can also retrieve information specifically about the file attachment, using the FID returned when requesting information about the node, using the url http://www.example.com/file/1.json:

https://gist.github.com/lhridley/804eb93016845f369535

Now, my question:

How specifically do you upload a file using RestWS, so that you create a file resource to then use when creating a node?
i use services not restWS, but the steps are quite similar on every REST service.

with your REST client. ie, restsharp, in my case im using Http (plugin for unity).
your first need to be connected, to do that call your server.dominio.co/site/apiName/user/login.json (you need to tick the option on your rest api, that enables user login service). also need to tick file creation permission.
if your are using token rememter to save it, also the session name, and session id myForm.AddHeader(session_name,session_id) (is the cookie). in my case i dont send it because http already do it for me. after that this is how i upload a file with c# and services, 

Hashtable hashdata = new Hashtable();

    WWWForm myForm = new WWWForm();
    myForm.AddField("file", base64Img);
    myForm.AddField("filename", name);
    myForm.AddField("filepath", "public://" + folderName);
    string path = server.dominio.co/site/apiName + "file";
    HTTP.Request theRequest = new HTTP.Request("post", path, myForm);

    theRequest.synchronous = true;
    theRequest.AddHeader("X-CSRF-Token", myTOKEN);
    theRequest.Send((request) =&gt;
    {
        if (request.response != null)
        {
            request.response.GetHeaders();

            string result = request.response.Text;
            hashdata = new Hashtable();
            hashdata = (Hashtable)JSON.JsonDecode(result);

        }

    });
    return hashdata;


will return the fid of the file just uploaded... after that you will need to update the field of the node where you want the file to be attached to... you will need a new REST request to update that node, method update, etc, etc

Hopes this helps a bit.... know it's not THE solution... but hope it points you the right way.