How to use mock-aws-s3 - 8 common examples

To help you get started, we’ve selected a few mock-aws-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 mapbox / cardboard / test / setup.js View on Github external
var Dynalite = require('dynalite');
var Cardboard = require('../');
var fakeAWS = require('mock-aws-s3');
var queue = require('queue-async');
var dynalite;

var config = module.exports.config = {
    accessKeyId: 'fake',
    secretAccessKey: 'fake',
    table: 'geo',
    endpoint: 'http://localhost:4567',
    bucket: 'test',
    prefix: 'test',
    region: 'us-east-1',
    s3: fakeAWS.S3() // only for mocking s3
};

var dyno = module.exports.dyno = require('dyno')(config);

module.exports.setup = function(t, multi) {
    dynalite = Dynalite({
        createTableMs: 0,
        updateTableMs: 0,
        deleteTableMs: 0
    });
    dynalite.listen(4567, function() {
        t.pass('dynalite listening');
        var cardboard = Cardboard(config);
        var q = queue(1);

        q.defer(cardboard.createTable, config.table);
github MathieuLoutre / grunt-aws-s3 / tasks / aws_s3.js View on Github external
}

		if (options.endpoint) {
			s3_options.endpoint = options.endpoint;
		}

		if (options.params) {
			if (!isValidParams(options.params)) {
				grunt.warn('"params" can only be ' + put_params.join(', '));
			}
		}

		// Allow additional (not required) options
		_.extend(s3_options, _.pick(options, ['maxRetries', 'sslEnabled', 'httpOptions', 'signatureVersion', 's3ForcePathStyle']));

		var s3 = new AWS.S3(s3_options);

		var dest;
		var is_expanded;
		var objects = [];
		var uploads = [];

		// Because Grunt expands the files array automatically,
		// we need to group the uploads together to make the difference between actions.
		var pushUploads = function() {

			if (uploads.length > 0) {
				objects.push({ action: 'upload', files: uploads });
				uploads = [];
			}
		};
github littlstar / s3-lambda / lib / S3.js View on Github external
constructor(config) {
    this.verbose = config.verbose || false
    this.encoding = config.encoding || 'utf8'
    if (config.localPath) {

      // use local files (using mock aws sdk)
      s3Mock.config.basePath = config.localPath
      this.s3Instance = new s3Mock.S3()
    } else {

      // use the aws sdk. attempt to use aws credentials in config.  if they
      // are not present, the aws sdk could pick them up in ~/.aws/credentials
      if (config.accessKeyId && config.secretAccessKey) {
        aws.config.update({
          accessKeyId: config.accessKeyId,
          secretAccessKey: config.secretAccessKey
        })
      }

      // Create AWS S3 object
      this.s3Instance = new aws.S3({
        maxRetries: config.maxRetries || 10,
        signatureVersion: config.signatureVersion || 'v4',
        httpOptions: {
github littlstar / s3-lambda / lib / S3.js View on Github external
constructor(config) {
    this.verbose = config.verbose || false
    this.encoding = config.encoding || 'utf8'
    if (config.localPath) {

      // use local files (using mock aws sdk)
      s3Mock.config.basePath = config.localPath
      this.s3Instance = new s3Mock.S3()
    } else {

      // use the aws sdk. attempt to use aws credentials in config.  if they
      // are not present, the aws sdk could pick them up in ~/.aws/credentials
      if (config.accessKeyId && config.secretAccessKey) {
        aws.config.update({
          accessKeyId: config.accessKeyId,
          secretAccessKey: config.secretAccessKey
        })
      }

      // Create AWS S3 object
      this.s3Instance = new aws.S3({
        maxRetries: config.maxRetries || 10,
        signatureVersion: config.signatureVersion || 'v4',
github MathieuLoutre / grunt-aws-s3 / tasks / aws_s3.js View on Github external
var filePairOptions = {
			differential: options.differential,
			stream: options.stream,
			flipExclude: false,
			exclude: false
		};

		// Replace the AWS SDK by the mock package if we're testing
		if (options.mock) {
			AWS = require('mock-aws-s3');
		}

		if (options.awsProfile) {
			var credentials = new AWS.SharedIniFileCredentials({profile: options.awsProfile});
			AWS.config.credentials = credentials;
		}

		if (['dots','progressBar','none'].indexOf(options.progress) < 0) {
			grunt.log.writeln('Invalid progress option; defaulting to dots\n'.yellow);
			options.progress = 'dots';
		}

		// List of acceptable params for an upload
		var put_params = ['CacheControl', 'ContentDisposition', 'ContentEncoding',
			'ContentLanguage', 'ContentLength', 'ContentMD5', 'Expires', 'GrantFullControl',
			'GrantRead', 'GrantReadACP', 'GrantWriteACP', 'Metadata', 'ServerSideEncryption',
			'StorageClass', 'WebsiteRedirectLocation', 'ContentType'];

		// Checks that all params are in put_params
		var isValidParams = function (params) {
github MathieuLoutre / grunt-aws-s3 / tasks / aws_s3.js View on Github external
}

		var filePairOptions = {
			differential: options.differential,
			stream: options.stream,
			flipExclude: false,
			exclude: false
		};

		// Replace the AWS SDK by the mock package if we're testing
		if (options.mock) {
			AWS = require('mock-aws-s3');
		}

		if (options.awsProfile) {
			var credentials = new AWS.SharedIniFileCredentials({profile: options.awsProfile});
			AWS.config.credentials = credentials;
		}

		if (['dots','progressBar','none'].indexOf(options.progress) < 0) {
			grunt.log.writeln('Invalid progress option; defaulting to dots\n'.yellow);
			options.progress = 'dots';
		}

		// List of acceptable params for an upload
		var put_params = ['CacheControl', 'ContentDisposition', 'ContentEncoding',
			'ContentLanguage', 'ContentLength', 'ContentMD5', 'Expires', 'GrantFullControl',
			'GrantRead', 'GrantReadACP', 'GrantWriteACP', 'Metadata', 'ServerSideEncryption',
			'StorageClass', 'WebsiteRedirectLocation', 'ContentType'];

		// Checks that all params are in put_params
		var isValidParams = function (params) {

mock-aws-s3

Mock AWS S3 SDK for Node.js

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis