Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added support for range requests with `getFile()`

  • Loading branch information...
commit e92640d96ea854b13bbcf79687fbb76e21df60bf 1 parent 49f2216
@fent fent authored
Showing with 13 additions and 3 deletions.
  1. +13 −3 lib/dropbox-node.js
View
16 lib/dropbox-node.js
@@ -31,7 +31,16 @@ DropboxClient.prototype.request =
, token_secret: optargs.secret || this.access_token_secret
};
- return request[method]({ uri: uri, oauth: oauth, body: body }, callback ?
+ var requestOptions = { uri: uri, oauth: oauth };
+ if (body) {
+ if (method === 'get') {
+ requestOptions.headers = { Range: body };
+ } else {
+ requestOptions.body = body;
+ }
+ }
+
+ return request[method](requestOptions, callback ?
function(err, res, body) {
if (err) return callback(err);
var contentType = res.headers['content-type'];
@@ -115,8 +124,9 @@ DropboxClient.prototype.createAccount = function(email, first_name, last_name
// user's Dropbox root.
DropboxClient.prototype.getFile = function(path, optargs, cb) {
if (typeof optargs == 'function') cb = optargs, optargs = {};
- var uri = CONTENT_API_URI + '/files/dropbox/' + escapePath(path);
- return this.get(uri, optargs, cb);
+ var uri = CONTENT_API_URI + '/files/dropbox/' + escapePath(path) +
+ (optargs.rev ? '?rev=' + optargs.rev : '');
+ return this.get(uri, optargs, optargs.range, cb);
}
Please sign in to comment.
Something went wrong with that request. Please try again.