Giter VIP home page Giter VIP logo

node-cloud's Introduction

node-cloud

A node module for interacting with different services of multiple clouds(AWS, Azure etc.)

###Installation: In your project's package.json add following line of code and then run npm install

{
  "dependencies": {
    "node-cloud": "https://github.com/D-Ne0/node-cloud"
  }
}

npm i node-cloud

###Usage: #####Accessing S3 service of AWS

var serviceName = 'FILE_STORAGE';
var providerName = 'AWSS3';
var config = {
  accessKeyId: '',
  secretAccessKey: ''
}
var aws = require('node-module')(serviceName, providerName, config);

All these functions return a Bluebird promise.

/**
 * bucket: bucket is S3 bucket
 * key: file name in S3
 */

// Upload content to S3
var content = 'Hello World'; // It can be a buffer or a stream or a simple string
aws.uploadContent(bucket, key, content);

// Upload file to S3
var filepath = '/tmp/kdjsd83839' // filepath on local server
aws.uploadFile(bucket, key, filepath);

// Download a file from S3 and save it locally
var saveFilepath = '/home/myuser/download.txt'; // path where file will be downloaded
aws.downloadFile(bucket, key, saveFilepath);

// Get a URL for a file on S3 that will expire in 1 hour by default
var opts = {expires: 7200}; // expires in seconds
var url = aws.getFileUrl(bucket, key, opts);

// Delete a file from S3
aws.deleteFile(bucket, key);

####Testing: These tests will store data on S3, they aren't just stubs. AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and S3_BUCKET environment variables must be defined.

AWS_ACCESS_KEY_ID='value' AWS_SECRET_ACCESS_KEY='value' S3_BUCKET='value' npm test

####Note: More services and cloud support will be added soon.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.