Skip to content
Browse files

Merge remote-tracking branch 'snakamura/put'

Conflicts:
	lib/dropbox-node.js
  • Loading branch information...
2 parents 01a6f06 + 3436c28 commit 87e28463aeec9a9dc1f5e13d6d4d26b6bf9beb29 @evnm committed
Showing with 33 additions and 24 deletions.
  1. +33 −24 lib/dropbox-node.js
View
57 lib/dropbox-node.js
@@ -76,7 +76,7 @@ DropboxClient.prototype.request =
// Convenience methods
['get', 'post', 'put'].forEach(function(method) {
- DropboxClient.prototype[method] = function(uri, optargs, body, callback) {
+ DropboxClient.prototype['_' + method] = function(uri, optargs, body, callback) {
return this.request(method, uri, optargs, body, callback);
};
});
@@ -93,7 +93,7 @@ DropboxClient.prototype.getAccessToken = function(email, pwd, cb) {
var uri = API_URI + '/token?' +
querystring.stringify({email: email, password: pwd});
var self = this;
- this.get(uri, {}, function(err, data) {
+ this._get(uri, {}, function(err, data) {
if (err) return cb(err);
// Store the key pair and fire callback.
self.access_token = data.token;
@@ -109,7 +109,7 @@ DropboxClient.prototype.getAccountInfo = function(optargs, cb) {
var uri = API_URI + '/account/info/' +
(optargs.status_in_response ? '?status_in_response=' +
optargs.status_in_response : '');
- this.get(uri, optargs, cb);
+ this._get(uri, optargs, cb);
}
@@ -124,9 +124,9 @@ DropboxClient.prototype.createAccount = function(email, first_name, last_name
, password: password
, status_in_response: optargs.status_in_response
}
- var uri = API_URI + '/account?' +
- querystring.stringify(params);
- this.get(uri, {}, cb);
+ var uri = API_URI + '/account?' + querystring.stringify(params);
+
+ this._get(uri, {}, cb);
}
@@ -137,7 +137,8 @@ DropboxClient.prototype.getFile = function(path, optargs, cb) {
else if (!optargs) optargs = {};
var uri = CONTENT_API_URI + '/files/' + this.root + '/' + escapePath(path) +
(optargs.rev ? '?rev=' + optargs.rev : '');
- return this.get(uri, optargs, optargs.range, cb);
+
+ return this._get(uri, optargs, optargs.range, cb);
}
@@ -147,6 +148,7 @@ DropboxClient.prototype.putFile = function(file, path, optargs, cb) {
var uri = CONTENT_API_URI + '/files_put/' + this.root + '/' + escapePath(path) +
'?' + stringifyParams(optargs);
var self = this;
+
fs.readFile(file, function(err, data) {
if (err) return cb(err);
self.request('put', uri, optargs, data, cb);
@@ -159,7 +161,8 @@ DropboxClient.prototype.put = function(content, path, optargs, cb) {
if (typeof optargs == 'function') cb = optargs, optargs = {};
var uri = CONTENT_API_URI + '/files_put/' + this.root + '/' + escapePath(path) +
'?' + stringifyParams(optargs);
- this.put(uri, optargs, content, cb);
+
+ this._put(uri, optargs, content, cb);
}
@@ -169,7 +172,8 @@ DropboxClient.prototype.getMetadata = function(path, optargs, cb) {
if (typeof optargs == 'function') cb = optargs, optargs = {};
var uri = API_URI + '/metadata/' + this.root + '/' + escapePath(path) + '?' +
stringifyParams(optargs);
- this.get(uri, optargs, cb);
+
+ this._get(uri, optargs, cb);
}
@@ -179,9 +183,10 @@ DropboxClient.prototype.getMetadata = function(path, optargs, cb) {
DropboxClient.prototype.getThumbnail = function(path, optargs, cb) {
if (typeof optargs == 'function') cb = optargs, optargs = {};
optargs = optargs || {};
- var uri = CONTENT_API_URI + '/thumbnails/' + this.root + '/' + escapePath(path) + '?' +
- stringifyParams(optargs);
- return this.get(uri, optargs, cb);
+ var uri = CONTENT_API_URI + '/thumbnails/' + this.root + '/' + escapePath(path) +
+ '?' + stringifyParams(optargs);
+
+ return this._get(uri, optargs, cb);
}
@@ -193,8 +198,10 @@ DropboxClient.prototype.copy = function(from_path, to_path, optargs, cb) {
optargs.root = this.root;
if (!optargs.from_copy_ref) optargs.from_path = from_path;
optargs.to_path = to_path;
- var uri = API_URI + '/fileops/copy?' + stringifyParams(optargs);
- this.get(uri, optargs, cb);
+ var uri = API_URI + '/fileops/copy?' + querystring.stringify(
+ {root: this.root, from_path: from_path, to_path: to_path});
+
+ this._get(uri, optargs, cb);
}
@@ -204,9 +211,9 @@ DropboxClient.prototype.copy = function(from_path, to_path, optargs, cb) {
DropboxClient.prototype.createFolder = function(path, optargs, cb) {
if (typeof optargs == 'function') cb = optargs, optargs = {};
var uri = API_URI + '/fileops/create_folder?' +
- querystring.stringify({root: this.root
- , path: path});
- this.get(uri, optargs, cb);
+ querystring.stringify({root: this.root, path: path});
+
+ this._get(uri, optargs, cb);
}
@@ -217,7 +224,8 @@ DropboxClient.prototype.deleteItem = function(path, optargs, cb) {
if (typeof optargs == 'function') cb = optargs, optargs = {};
var uri = API_URI + '/fileops/delete?' +
querystring.stringify({root: this.root, path: path});
- this.get(uri, optargs, cb);
+
+ this._get(uri, optargs, cb);
}
@@ -227,10 +235,9 @@ DropboxClient.prototype.deleteItem = function(path, optargs, cb) {
DropboxClient.prototype.move = function(from_path, to_path, optargs, cb) {
if (typeof optargs == 'function') cb = optargs, optargs = {};
var uri = API_URI + '/fileops/move?' +
- querystring.stringify({root: this.root
- , from_path: from_path
- , to_path: to_path});
- this.get(uri, optargs, cb);
+ querystring.stringify({root: this.root, from_path: from_path, to_path: to_path});
+
+ this._get(uri, optargs, cb);
}
@@ -241,7 +248,8 @@ DropboxClient.prototype.search = function(path, query, optargs, cb) {
optargs.query = query;
var uri = API_URI + '/search/' + this.root + '/' + escapePath(path) + '?' +
stringifyParams(optargs);
- this.get(uri, optargs, cb);
+
+ this._get(uri, optargs, cb);
}
@@ -262,7 +270,8 @@ DropboxClient.prototype.delta = function(cursor, optargs, cb) {
var uri = API_URI + '/delta' +
(cursor ? '?' + querystring.stringify({cursor: cursor}) : '')
- this.post(uri, optargs, cb);
+
+ this._post(uri, optargs, cb);
}

0 comments on commit 87e2846

Please sign in to comment.
Something went wrong with that request. Please try again.