Node JS Dropbox – Upgrade from Version 1 to Version 2

 In CloudRail

If you are using any of the official Dropbox SDKs, you might have received this email in your inbox:

dropbox-upgrade-email

As many of the unofficial Node.js SDKs rely on version 1, it might end up that whatever way you have chosen to include Dropbox in your Node.js application will break. And of course, you can’t be guaranteed that they will update in response to version 1 becoming depreciated.

So, this is the perfect time to make the upgrade to CloudRail for your Node JS Dropbox implementation.

Why you should use CloudRail for your Dropbox JS Project

As a single interface, CloudRail has many advantages over other libraries that you can use for your Dropbox Node.Js project:

  • Dropbox isn’t the only Cloud Storage in it: CloudRail aggregates and compiles different Cloud Storage services. As well as Dropbox, using CloudRail you can add to your project support for Google Drive, Box & OneDrive.
  • Cloud Storage isn’t the only interface in it: CloudRail also abstracts the APIs of other cloud based services. We call these bundles interfaces. In CloudRail, as well as Cloud Storage, you also have interfaces for Social Media Profiles, Payment Services, SMS, Email and Points of Interest.
  • No Middleware: CloudRail is completely middleware free. The data is passed from your project straight to the cloud service provider you are using (e.g. Dropbox). None of this data ever passes through a CloudRail server. You don’t have to worry about your project not functioning if our servers are down, nor about the security of your (or your users) personal data.
  • Completely Free: As we don’t have to worry about keeping servers running, CloudRail is completely free to use (unlike other, similar libraries). To repeat: CloudRail is completely free, for both personal and commercial projects.

Getting started with Node JS, Dropbox and CloudRail

Your first step will be to download the CloudRail Library. You have several options for this.

Via NPM – Dropbox, and other Cloud Storage APIs in one Bundle.

The most popular option for getting Node & Dropbox integration working is to use NPM to download the CloudRail SDK:

  • Create a new Node.js project or switch to an existing one.
  • Execute npm install –save cloudrail-si in your project’s folder.
  • Use require(“cloudrail-si”) in your code to include the library.

You can also view us on NPM here: NPM Dropbox

Using Manual extraction for Dropbox Node via CloudRail

  • Download the SDK here.
  • Unzip the file.
  • Create a new Node.js project or switch to an existing one.
  • Use require to include the index.js file in your code.

Using Localhost to Setup Dropbox Node.js

To keep this guide brief, we will use localhost to set up the Node Dropbox Javascript Library via CloudRail. This will allow you to do local testing, and is a good starter guide for discovering how CloudRail and the Node JS Dropbox implementation works.

If, however, after reading this you still need some help in how to integrate with a pre-existing, “real”, server, you can take a look at our example of a OAuth 2.0 integration with Express and Mongo integration.

Initialising the Node JS Dropbox CloudRail Integration

The code example below makes usage of the ‘opn’ library for opening up URLs in the local browser: https://github.com/sindresorhus/opn

To follow along with this code example, you will also need to set “http://localhost:12345/auth” as an allowed redirect URI in your Dropbox App Dashboard (on the Dropbox website).

As you can see, in the code we are creating a redirectReciever that specifies exactly how the Node JS Dropbox authentication should be handled.

The other important part is line 19. This is where we instantiate the Dropbox object from the CloudRail Library. You will want to replace [clientID] and [clientSecret] with the current values from your Dropbox application.

From here you can then call any of the functions included from the cs object. For a full listing of what functions are available, take a look at the CloudRail Documentation. However, to get you acquainted with using Dropbox Javascript via node, take a look at the example code below.

Downloading, Reading MetaData, Zipping & ReUploading a file with Dropbox & Node.js

Now, one important thing to note about the code above for our Node.js Dropbox Javascript API< implementation is that it doesn't just have to be Dropbox. That is, if you were to also include Google Drive in your application, the exact same code would be used for Drive (just replacing the "cs" with the name of the variable you have instantiated for your Google Drive object).

Other advantages of using CloudRail to Upgrade Node.Js Dropbox from V1 to V2

The first main benefit of using CloudRail is to consider how many different interfaces and Cloud Services you can connect up to:

  • Cloud Storage: With Dropbox, Google Drive, Box and OneDrive.
  • Social Profiles: With Facebook, Google+, Twitter, LinkedIn, WindowsLive, Yahoo/strong>,GitHub, Slack and Instagram.
  • Payment: With PayPal and Stripe.
  • SMS: With Twilio and Nexmo.
  • Email With SendGrid and MailJet.
  • Points of Interest: With FourSquare, Yelp and Google Places.

And not only do you get all of these integrations (all in the time it takes you to integrate the Dropbox Node implementation as above) CloudRail also has these benefits:

  • No Middleware: As stated above, CloudRail is completely absent from having middleware. There is a direct data connection between your app and the Cloud Service providers whose API you are using. You don’t have to worry about if our servers are up and running and you don’t have to worry about the security of your data in regards to us seeing it. Even if we wanted to (and we don’t) we can’t.
  • Constant Updates: CloudRail is updated at least once a week. When an API provider, for example Dropbox, changes their API implementation, CloudRail will be updated to use the newest version of that API. This means that for you, saving yourself from yet another API deprecation headache is as simple as updating the CloudRail library in your application, and not having to change your code.
  • Sensible Methods and Documentation: Each service within an interface uses the same functions. They also have the same inputs, and the same outputs. This means that, say, once you have made some code to upload a specific file to Dropbox, the same code can be reused for all other services. We also keep the CloudRail documentation constantly updated, and change it according to improvements suggested by users of CloudRail.
  • Free: CloudRail is free. For personal or commercial projects.

So what are you waiting for? Upgrade from Version 1 of Dropbox Node.js to Version 2, and never have to worry about doing this kind of upgrade ever again.

Recent Posts