After the release of the amazing google spreadsheet module comes another exciting release by the team at Mindblaze.
Lo and behold the Streaming S3 module that contains tons of exciting features for budding nodeJS programmers who would like to play with Amazon S3. We were not happy with what was out there so we made our own!
Head-on over to GitHub at http://mindblaze.github.io/streaming-s3/
var Streaming-S3 = require('streaming-s3'), fs = require('fs'); var fStream = fs.CreateReadStream(__dirname + '/video.mp4'); var uploader = new Streaming-S3(fStream, 'accessKey', 'secretKey', { Bucket: 'example.streaming-s3.com', Key: 'video.mp4', ContentType: 'video/mp4' }, function (err, resp, stats) { if (err) return console.log('Upload error: ', e); console.log('Upload stats: ', stats); console.log('Upload successful: ', resp); } );
var Streaming-S3 = require('streaming-s3'), request = require('request'); var rStream = request.get('http://www.google.com'); var uploader = new Streaming-S3(rStream, 'accessKey', 'secretKey', { Bucket: 'example.streaming-s3.com', Key: 'google.html', ContentType: 'text/html' }, { concurrentParts: 2, waitTime: 10000, retries: 1, maxPartSize: 10*1024*1024, } ); uploader.begin(); // important if callback not provided. uploader.on('data', function (bytesRead) { console.log(bytesRead, ' bytes read.'); }); uploader.on('part', function (number) { console.log('Part ', number, ' uploaded.'); }); // All parts uploaded, but upload not yet acknowledged. uploader.on('uploaded', function (stats) { console.log('Upload stats: ', stats); }); uploader.on('finished', function (resp, stats) { console.log('Upload finished: ', resp); }); uploader.on('error', function (e) { console.log('Upload error: ', e); });
Posted By
Mindblaze Team
Categories
Node.js, Tech
Tags
Amazon S3, node.js