Cloudrail Tutorial
Cloudrail Useful Resources
Selected Reading
- Cloudrail - Coding
- Cloudrail - Setup
- Cloudrail - Social Login
- Cloudrail - IOS
- Cloudrail - Node.js
- Cloudrail - Java
- Cloudrail - Android
- Cloudrail - Overview
- Cloudrail - Home
Cloudrail Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Cloudrail - Node.js
Cloudrail - Node.js
This section gives an introduction on how to use CloudRail s Node.js SDK.
Setup
The easiest way to install is via NPM. Simply use the following command −
npm install cloudrail-si
Usage
The following example shows how to create a new folder and upload a file from the local machine to the newly created folder on any cloud storage provider.
javascript const cloudrail = require("cloudrail-si"); cloudrail.Settings.setKey("[CloudRail License Key]"); // let cs = new cloudrail.services.Box(redirectReceiver, "[cpentIdentifier]", "[cpentSecret]", "[redirectUri]", "[state]"); // let cs = new cloudrail.services.OneDrive(redirectReceiver, "[cpentIdentifier]", "[cpentSecret]", "[redirectUri]", "[state]"); // let cs = new cloudrail.services.GoogleDrive(redirectReceiver, "[cpentIdentifier]", "[cpentSecret]", "[redirectUri]", "[state]"); let cs = new cloudrail.services.Dropbox(redirectReceiver, "[cpentIdentifier]", "[cpentSecret]", "[redirectUri]", "[state]"); cs.createFolder("/TestFolder", (err) => { // <--- if (err) throw err; let fileStream = fs.createReadStream("UserData.csv"); let size = fs.statSync("UserData.csv").size; cs.upload("/TestFolder/Data.csv", fileStream, size, false, (err) => { // <--- if (err) throw err; console.log("Upload successfully finished"); }); });Advertisements