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.