Skip to content

Instantly share code, notes, and snippets.

@shrikanthkr
Last active August 29, 2015 14:00
Show Gist options
  • Save shrikanthkr/b1e217afbac9f074a23d to your computer and use it in GitHub Desktop.
Save shrikanthkr/b1e217afbac9f074a23d to your computer and use it in GitHub Desktop.
Using grunt aws S3

#create package.json { "name": "my-project-name", "version": "0.1.0", "devDependencies": { "grunt": "~0.4.2", "grunt-contrib-jshint": "~0.6.3", "grunt-contrib-nodeunit": "~0.2.0", "grunt-contrib-uglify": "~0.2.2", "grunt-aws-s3": "~0.8.0" } } #Grunt file ###Gruntfile.js

module.exports = function(grunt) {
        grunt.initConfig({
        aws: grunt.file.readJSON('aws.json'),
        aws_s3: {
         options: {
            accessKeyId: '<%= aws.key %>', // Use the variables
            secretAccessKey: '<%= aws.secret %>', // You can also use env variables
            region: 'us-east-1', //can be found from url when u click on your bucket
            uploadConcurrency: 10, // 10 simultaneous uploads
            downloadConcurrency: 5 // 5 simultaneous downloads
        },
            staging: {
                options: {
                    bucket: '<%= aws.bucket %>',
                    differential: true // Only uploads the files that have changed, //needs dest  
                },
                files: [
                 /*  {dest: 'app/', differential:false,'action': 'delete'},*/
                 {'action': 'upload', expand: true, cwd: './../dist/', src: ['**'], dest: 'app/', stream: true, differential: true} //I need to upoad                    
                 //{'action': 'upload', expand: true, cwd: './../dist/', src: ['**'], stream: true, differential: false} To force upload
              ]
            },
        }
    });
grunt.loadNpmTasks('grunt-aws-s3');
};

aws.json refers to a simple json file in the same directory

npm install

grunt aws_s3

#Sample Output

Uploading to https://s3.amazonaws.com/bucket-name/
.......................

#References

Grunt AWS S3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment