Is this intentional?
In my Node.js-based client, using POST causes the XMLHttpRequest wrapper to reset the body to null, because it is not a known Form format. Changing POST to PUT fixes the issue.
@snowfix Thank you for reporting this issue!
The writeFileUsingPut name is misleading, but there is a good reason for using POST -- it avoids a CORS preflight in browsers. Also, I wanted to keep the node.js behavior as close as possible to the browser behavior.
What object are you passing to writeFile?
I hope that Client.writeFile in the unit tests always delegates to Client.writeFileUsingPut on node.js, so writeFieUsingPut should be able to write String instances to text files.
@snowfix I'm afraid the problem lies in the node-xmlhttprequest wrapper. The XHR specification doesn't distinguish between POST and PUT, and the code works as intended on the browser.
I'm working on a replacement XHR wrapper for node.js that will support binary files via Buffer and ArrayBuffer.
In the short run, it probably makes the most sense to keep using your patched version of node.js. I hope to get this library done soon, and I'll make a dropbox.js release that uses it instead of node-xmlhttprequest.
This is good news. I just forked my own copy of node-xmlhttprequest because I wanted to not only make the stuff work, but also to enhance it to make it work behind proxies (probably by using node-tunnel just like request is doing). Would you have interest in this type of contribution?
BTW, I am using a patched version of node-XMLHttpRequest, not of the entire Node.js.
@snowfix I think it's better to wait until I make a first stable release, because I'll probably be changing the code like crazy until I get all the features working.
After that, definitely go for it!
@snowfix I have released 0.9.1-beta1, which is a node.js-only update that supports node.js Buffers and ArrayBuffers. Please give it a try!
node-xhr2 still needs more work, I haven't added tests for events and network error handling. I think the code for send() is pretty stable though, and you can start looking at figuring out proxy support.
I'm closing this bug. Let's discuss proxy support in the node-xhr2 issue tracker.