How to use s3 - 10 common examples

To help you get started, we’ve selected a few s3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DanielHindi / aws-s3-zipper / index.js View on Github external
callback = params.maxFileCount;
            params.maxFileCount = null;
        }
        else if (params.maxFileCount > 0)
            bucketParams.MaxKeys = params.maxFileCount;

        var t = this;

        var files ={};
        files.Contents = [];

        var options = {
            s3Client: this.s3bucket
            // more options available. See API docs below.
        };
        var client = s3.createClient(options);

        var realParams = {
            s3Params: bucketParams,
            recursive: params.recursive
        };

        var emitter = client.listObjects(realParams);
        emitter.on('data', function (data) {
            if(data && data.Contents) {
                files.Contents = files.Contents.concat(data.Contents);
            }
        });

        emitter.on('end', function () {
            var data = files;
            console.log('end');
github clappr / clappr / upload.js View on Github external
var upload = function(localDir, prefix, deleteRemoved, cb) { // eslint-disable-line no-unused-vars
  var awsOptions = JSON.parse(fs.readFileSync('./aws.json'))
  var client = s3.createClient({ s3Options: awsOptions })
  var params = { localDir: localDir, deleteRemoved: !!deleteRemoved, s3Params: { Bucket: 'cdn.clappr.io', Prefix: prefix } }
  var uploader = client.uploadDir(params)
  uploader.on('error', function(err) { console.error('unable to sync:', err.stack) })
  uploader.on('end', function() { console.log('done uploading for ' + prefix) })
}
github kacole2 / s3motion / s3motion.js View on Github external
var s3Client = function(s3ClientArgs) {
	var client = s3.createClient({
	  s3Options: {
	    accessKeyId: s3ClientArgs.accessKeyId,
	    secretAccessKey: s3ClientArgs.secretAccessKey,
	    endpoint: s3ClientArgs.endpoint
	    // any other options are passed to new AWS.S3()
	    // See: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#constructor-property
	  },
	});
	return client;
}
github fluuuid / codedoodl.es / utils / uploadToS3.js View on Github external
function getClient(creds) {
    var client = s3.createClient({
        maxAsyncS3: 20,     // this is the default
        s3RetryCount: 3,    // this is the default
        s3RetryDelay: 1000, // this is the default
        multipartUploadThreshold: 20971520, // this is the default (20 MB)
        multipartUploadSize: 15728640, // this is the default (15 MB)
        s3Options: {
            accessKeyId: creds.aws.id,
            secretAccessKey: creds.aws.key,
            region : creds.aws.region
            // any other options are passed to new AWS.S3()
            // See: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#constructor-property
        },
    });

    return client;
}
github wongcyrus / AWSCloudLab / AWSCloudLabCore / lib / S3Manager.js View on Github external
return new Promise((resolve, reject) => {
            let s3 = new AWS.S3();
            let options = {
                s3Client: s3
            };
            let client = s3Client.createClient(options);
            let params = {
                localFile: filePathname,
                s3Params: {
                    Bucket: this.bucket,
                    Key: key
                }
            };
            console.log(params);
            let downloader = client.downloadFile(params);
            downloader.on('error', (err) => {
                console.error("unable to download:", err.stack);
                reject(err);
            });
            downloader.on('progress', () => {
                console.log("progress", downloader.progressAmount, downloader.progressTotal);
            });
github jdxcode / npm-register / lib / storage / s3.js View on Github external
constructor () {
    super()
    var settings = config.s3.params
    settings.params = {}
    settings.params.Bucket = config.s3.bucket

    this.client = Promise.promisifyAll(require('s3').createClient({
      s3Client: Promise.promisifyAll(new AWS.S3(settings))
    }))
    console.log(`Saving files to s3 bucket ${config.s3.bucket}`)
  }
github clappr / clappr / tasks / upload.js View on Github external
var upload = function(localDir, prefix, deleteRemoved, cb) {
  var awsOptions = JSON.parse(fs.readFileSync('./aws.json'));
  var client = s3.createClient({s3Options: awsOptions});
  var params = {localDir: localDir, deleteRemoved: !!deleteRemoved, s3Params: {Bucket: "cdn.clappr.io", Prefix: prefix}};
  var uploader = client.uploadDir(params);
  uploader.on('error', function(err) { console.error("unable to sync:", err.stack); });
  uploader.on('end', function() { console.log("done uploading for " + prefix); });
}
github streamroot / clappr-p2phls-plugin / Gulpfile.js View on Github external
gulp.task('upload', function(b) {
  var awsOptions = JSON.parse(fs.readFileSync('./aws.json'));
  var client = s3.createClient({s3Options: awsOptions});
  var params = {localDir: "./dist/", deleteRemoved: true, s3Params: {Bucket: "cdn.clappr.io", Prefix: "bemtv/latest/"}};
  var uploader = client.uploadDir(params);
  uploader.on('error', function(err) { console.error("unable to sync:", err.stack); });
  uploader.on('end', function() { console.log("done uploading"); });
  return;
});

s3

high level amazon s3 client. upload and download files and directories

MIT
Latest version published 10 years ago

Package Health Score

47 / 100
Full package analysis

Popular s3 functions