upload file to s3 cloud with knox

knox  is the latest .

//you have to download the knox folder from knox git .
var knox = require('./lib/knox')
  , sys = require('sys')
  , fs = require('fs');
  var client = knox.createClient({
    key: 'your key'
  , secret: 'sec key '
  , bucket: 'buck name '
});
//you can do by put or putFile
// fs.readFile('01.png', function(err, buf){
  // var req = client.put('01.png', {
      // 'Content-Length': buf.length
      // ,'Content-Type': 'text/plain'
  // });
  // req.on('response', function(res){
    // if (200 == res.statusCode) {
      // console.log('saved to %s', req.url);
    // }
  // });
  // req.end(buf);
// });

client.putFile('01.png', '02.png', function(err, res){
    if (200 == res.statusCode) {
      console.log('saved to ');
    }
  // Logic
});  d

Ref :

https://github.com/LearnBoost/knox

Advertisements

About rahul23134654

Hi, I am Rahul Meha , B.E. in (I.T.)
This entry was posted in Node.js. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s