javascriptnode.jsdropbox-apidropbox-sdk-js

Problems Downloading files using Dropbox JavaScript SDK


I need to figure out where my files are downloading when I use the filesDownload(). I don't see an argument for file destination. Here's my code:

require('isomorphic-fetch'); 
var Dropbox = require('dropbox').Dropbox;
var dbx = new Dropbox({ accessToken: 'accessToken', fetch});

dbx.filesDownload({path: 'filepath}).
  then(function(response) {
  console.log(response);
})
.catch(function(error) {
  console.log(error);
});

I'm getting a successful callback when I run the code but I don't see the file anywhere.

I need to know where my files are downloading to and how to specify the file destination in my function.

Thanks, Gerald

I've used the function as described in the SDK's documentation (http://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesDownload__anchor) but I have no idea where my file goes.

Expected Result: Files are downloaded to Dropbox to path that I have designated.

Actual Results: I get a successful callback from Dropbox but I cannot find the files downloaded.


Solution

  • In Node.js, the Dropbox API v2 JavaScript SDK download-style methods return the file data in the fileBinary property of the object they pass to the callback (which is response in your code).

    You can find an example of that here:

    https://github.com/dropbox/dropbox-sdk-js/blob/master/examples/javascript/node/download.js#L20

    So, you should be able to access the data as response.fileBinary. It doesn't automatically save it to the local filesystem for you, but you can then do so if you want.