Binary file support in node.js #28

pwnall opened this Issue Nov 26, 2012 · 8 comments


None yet
3 participants

pwnall commented Nov 26, 2012

We're currently using node-XMLHttpRequest to get an XHR-like API on node.js. The following issues in the library seem to be the main roadblocks to supporting binary files.

Alternatively, we could use a completely different Dropbox.Xhr implementation on node.js.

@ghost ghost assigned pwnall Nov 26, 2012

terehov commented Jan 19, 2013

Hello! Are there any updates on this topic (uploading binary data to dropbox using dropbox.js)?


pwnall commented Jan 19, 2013

@terehov Sorry, I don't have any good news so far. I've been focusing on Chrome extensions support up until now. On the bright side, I promise this is the first thing on my list once I shift my focus to node.js.

Under the hood, we're using a node library that implements the XMLHttpRequest API. The author promised to support XHR level 2 in an upcoming version. Unfortunately, that library hasn't been updated in a while.

If you can find another library that supports ArrayBuffers (and, ideally, node.js Buffer objects as well), dropbox.js could use it without any modifications -- we do feature detection everywhere. If you can point me to such a library, I'll try running the test suite against it and, if it works, I'll swap it in.

Sorry this has taken forever 😢


pwnall commented Jan 29, 2013

@terehov The master version of dropbox.js supports binary uploads and downloads on node.js, via Buffers and ArrayBuffers / ArrayBufferViews. Please give it a try!

@pwnall pwnall closed this Jan 29, 2013


pwnall commented Jan 29, 2013

@terehov I released a 0.9.1-beta1 node.js-only update that has binary support, to make it easier for you (and anyone else that might be reading this) to give this a try.

The price of binary file support is that I had to replace an old and pretty well tested XHR wrapper with a new version that I just wrote. Therefore, testing would be really appreciated!

terehov commented Jan 30, 2013

Wow, thanks a lot!
I definitely gonna try it in the next couple of days!
Thanks again :-)

terehov commented Feb 7, 2013

Hi pwnall,

I was playing around but couldn't manage to upload a file.
Is there a chance you could post me a node.js example reading a gif/jpg file from file system and uploading it to github? Would be great!

thx :-)

I don't know if this will come in handy, but here is a quick example I'm doing with the request library pulling an image from the web and pushing it into my dropbox.

var pathToDir = "";
var image = "name-of-image.jpg";
var pathToImage = pathToDir + image;
request(pathToImage, { encoding: null }, function(error, response, body){
    db_client.writeFile(image, body, function(error, stat){

terehov commented Feb 7, 2013

Thanks, that helped a lot :-) Now it works! I guess encoding was my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment