Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Escape spaces in path strings.

  • Loading branch information...
commit 33a025ae17ff143b93e2dc45882eb53abf8fe649 1 parent 5e24ff7
@evnm authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/dropbox-node/index.js
View
10 lib/dropbox-node/index.js
@@ -29,6 +29,7 @@ DropboxClient.prototype.getAccountInfo = function(optargs, callback) {
// Retrieves contents of a file specified by path argument, relative to
// user's Dropbox root.
DropboxClient.prototype.getFile = function(path, callback) {
+ path = path.replace(/ /g, '%20');
this.oauth.get(CONTENT_API_URI + API_VERSION + '/files/dropbox/' + path,
this.access_token, this.access_token_secret,
function(err, data, res) {
@@ -49,6 +50,7 @@ DropboxClient.prototype.putFile = function(file, path, callback) {
'Content-type: application/octet-stream\r\n' +
'\r\n' + file_contents + '\r\n' +
'--' + boundary + '--';
+ path = path.replace(/ /g, '%20');
this.oauth.post(CONTENT_API_URI + API_VERSION + '/files/dropbox/' + path +
'?file=' + file,
this.access_token, this.access_token_secret,
@@ -63,6 +65,7 @@ DropboxClient.prototype.putFile = function(file, path, callback) {
// Dropbox root.
DropboxClient.prototype.getMetadata = function(path, optargs, callback) {
if (typeof optargs == 'function') callback = optargs, optargs = null;
+ path = path.replace(/ /g, '%20');
this.oauth.get(API_URI + API_VERSION + '/metadata/dropbox/' + path +
(optargs ? '?' + querystring.stringify(optargs) : ''),
this.access_token, this.access_token_secret,
@@ -77,6 +80,7 @@ DropboxClient.prototype.getMetadata = function(path, optargs, callback) {
// valid size specifiers.
DropboxClient.prototype.getThumbnail = function(path, optargs, callback) {
if (typeof optargs == 'function') callback = optargs, optargs = null;
+ path = path.replace(/ /g, '%20');
this.oauth.get(CONTENT_API_URI + API_VERSION + '/thumbnails/dropbox/' + path
+ (optargs ? '?' + querystring.stringify(optargs) : ''),
this.access_token, this.access_token_secret,
@@ -89,6 +93,8 @@ DropboxClient.prototype.getThumbnail = function(path, optargs, callback) {
// See https://www.dropbox.com/developers/docs#fileops-copy for explanation
// of arguments.
DropboxClient.prototype.copy = function(from_path, to_path, callback) {
+ from_path = from_path.replace(/ /g, '%20');
+ to_path = to_path.replace(/ /g, '%20');
this.oauth.get(API_URI + API_VERSION + '/fileops/copy?from_path=' +
from_path + '&root=dropbox&to_path=' + to_path,
this.access_token, this.access_token_secret,
@@ -102,6 +108,7 @@ DropboxClient.prototype.copy = function(from_path, to_path, callback) {
// See https://www.dropbox.com/developers/docs#fileops-create-folder
// for explanation of arguments.
DropboxClient.prototype.createFolder = function(path, callback) {
+ path = path.replace(/ /g, '%20');
this.oauth.get(API_URI + API_VERSION + '/fileops/create_folder?path='
+ path +'&root=dropbox',
this.access_token, this.access_token_secret,
@@ -115,6 +122,7 @@ DropboxClient.prototype.createFolder = function(path, callback) {
// See https://www.dropbox.com/developers/docs#fileops-delete for
// explanation of arguments.
DropboxClient.prototype.deleteItem = function(path, callback) {
+ path = path.replace(/ /g, '%20');
this.oauth.get(API_URI + API_VERSION + '/fileops/delete?path=' +
path + '&root=dropbox',
this.access_token, this.access_token_secret,
@@ -128,6 +136,8 @@ DropboxClient.prototype.deleteItem = function(path, callback) {
// See https://www.dropbox.com/developers/docs#fileops-move for
// explanation of arguments.
DropboxClient.prototype.move = function(from_path, to_path, callback) {
+ from_path = from_path.replace(/ /g, '%20');
+ to_path = to_path.replace(/ /g, '%20');
this.oauth.get(API_URI + API_VERSION + '/fileops/move?from_path=' +
from_path + '&root=dropbox&to_path=' + to_path,
this.access_token, this.access_token_secret,
Please sign in to comment.
Something went wrong with that request. Please try again.