How to create a folder in dropbox using nodejs

Posted By : Chandan Kumar Singh | 19-May-2016

First of all get the access token by authorizing the user from dropbox,how to do is explained in my this blog http://www.oodlestechnologies.com/blogs/How-to-get-account-information-of-Dropbox-user-using-nodejs.

we are going to expand the dropbox.js file and adding the method createDir

In dropbox.js return method add this piece of code.

 createDir: function(path, cb) {
	Options = {
  		url: https://api.dropbox.com/1/fileops/create_folder,
    		json: true,
    		headers: {
      			"Authorization": "Bearer " + access_token
   		 },
   		 form:  {root:"auto", path:path}

}
          	request.post(options, function(err, res, body) {
        	cb(err, res, body);
      });
    },

 

And in drop.js file add this piece of code.

 api.createDir('/test/testdir/',function(err, res, body){
	if(!err) {
	console.log(“success”);
	}
});
 

/test/testdir/ this is the nested directory path, in test directory we have created testdir directory.

We have done.

About Author

Author Image
Chandan Kumar Singh

Chandan is a bright Web Developer with expertise in Java and Spring framework and ORM tools Hibernate. He loves technologies like Blockchain and IoT.

Request for Proposal

Name is required

Comment is required

Sending message..