NOTE: AwsSum is now deprecated. Please use aws-sdk instead.
This is an AwsSum
plugin!
You'll need to add awssum-amazon-s3 to your package.json dependencies. Both awssum and awssum-amazon are pulled in as peer dependencies.
List all your buckets:
var fmt = require('fmt');
var amazonS3 = require('awssum-amazon-s3');
var s3 = new amazonS3.S3({
'accessKeyId' : process.env.ACCESS_KEY_ID,
'secretAccessKey' : process.env.SECRET_ACCESS_KEY,
'region' : amazonS3.US_EAST_1
});
s3.ListBuckets(function(err, data) {
fmt.dump(err, 'err');
fmt.dump(data, 'data');
});
Streaming uploads:
var fmt = require('fmt');
var amazonS3 = require('awssum-amazon-s3');
var s3 = new amazonS3.S3({
'accessKeyId' : process.env.ACCESS_KEY_ID,
'secretAccessKey' : process.env.SECRET_ACCESS_KEY,
'region' : amazonS3.US_EAST_1
});
// you must run fs.stat to get the file size for the content-length header (s3 requires this)
fs.stat(__filename, function(err, file_info) {
var bodyStream = fs.createReadStream( __filename );
var options = {
BucketName : bucket,
ObjectName : 'amazon.js',
ContentLength : file_info.size,
Body : bodyStream
};
s3.PutObject(options, function(err, data) {
fmt.dump(err, 'err');
fmt.dump(data, 'data');
});
});
Streaming downloads:
var fmt = require('fmt');
var amazonS3 = require('awssum-amazon-s3');
var s3 = new amazonS3.S3({
'accessKeyId' : process.env.ACCESS_KEY_ID,
'secretAccessKey' : process.env.SECRET_ACCESS_KEY,
'region' : amazonS3.US_EAST_1
});
var options = {
BucketName : 'pie-17',
ObjectName : 'javascript-file.js',
};
s3.GetObject(options, { stream : true }, function(err, data) {
fmt.dump(err, 'err');
fmt.dump(data, 'data');
// stream this file to stdout
fmt.sep();
fmt.title('The File');
data.Stream.pipe(process.stdout);
data.Stream.on('end', function() {
fmt.sep();
});
});
Docs: ListBuckets on AWS
Docs: DeleteBucket on AWS
Docs: DeleteBucketCors on AWS
Docs: DeleteBucketLifecycle on AWS
Docs: DeleteBucketPolicy on AWS
Docs: DeleteBucketTagging on AWS
Docs: DeleteBucketWebsite on AWS
Docs: ListObjects on AWS
Docs: GetBucketAcl on AWS
Docs: GetBucketCors on AWS
Docs: GetBucketLifecycle on AWS
Docs: GetBucketPolicy on AWS
Docs: GetBucketTagging on AWS
Docs: GetBucketLocation on AWS
Docs: GetBucketLogging on AWS
Docs: GetBucketNotification on AWS
Docs: GetBucketObjectVersions on AWS
Docs: GetBucketRequestPayment on AWS
Docs: GetBucketVersioning on AWS
Docs: GetBucketWebsite on AWS
Docs: CheckBucket on AWS
Docs: ListMultipartUploads on AWS
Docs: CreateBucket on AWS
Docs: PutBucketAcl on AWS
Docs: PutBucketCors on AWS
Docs: PutBucketLifecycle on AWS
Docs: PutBucketPolicy on AWS
Docs: PutBucketLogging on AWS
Docs: PutBucketNotification on AWS
Docs: PutBucketTagging on AWS
Docs: PutBucketRequestPayment on AWS
Docs: PutBucketVersioning on AWS
Docs: PutBucketWebsite on AWS
Docs: DeleteObject on AWS
Docs: DeleteMultipleObjects on AWS
Docs: GetObject on AWS
Docs: GetObjectAcl on AWS
Docs: GetObjectTorrent on AWS
Docs: GetObjectMetadata on AWS
Docs: OptionsObject on AWS
Docs: PostObjectRestore on AWS
Docs: PutObject on AWS
Docs: PutObjectAcl on AWS
Docs: CopyObject on AWS
Docs: InitiateMultipartUpload on AWS
Docs: UploadPart on AWS
Docs: UploadPartCopy on AWS
Docs: CompleteMultipartUpload on AWS
Docs: AbortMultipartUpload on AWS
Docs: ListParts on AWS
Written by Andrew Chilton - Blog - Twitter.
- Copyright 2011-2013 Apps Attic Ltd. All rights reserved.
- Copyright 2013 Andrew Chilton. All rights reserved.
(Ends)