Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files not being written into bucket folders #125

Closed
gerrymiller opened this issue May 1, 2014 · 4 comments
Closed

Files not being written into bucket folders #125

gerrymiller opened this issue May 1, 2014 · 4 comments

Comments

@gerrymiller
Copy link

Hi there,

I was so happy to stumble across grunt-s3, as I was previously having to upload all my files manually. Thank you!

I'm having two issues. First, files are uploading to the root of my bucket fine, but files that are supposed to end up in folders are ending up in the root but named like this:

images%2Fmyimage.png

Here's my configuration:

s3: {
            options: {
                key: 'MyKey',
                secret: 'MySecretKey,
                bucket: 'MyBucketName',
                access: 'public-read',
                headers: {
                    // Two Year cache policy (1000 * 60 * 60 * 24 * 730)
                    //'Cache-Control': 'max-age=630720000, public',
                    //'Expires': new Date(Date.now() + 63072000000).toUTCString()
                }
            },
            dist: {
                options: {
                    encodePaths: true,
                    maxOperations: 20
                },
                upload: [{
                    src: 'dist/**',
                    dest: '',
                    rel: 'dist',
                    options: { gzip: true }
                }]
            }
        }

Also, when I run grunt s3 it works, but I get this error:

Loading "s3.js" tasks...ERROR
>> TypeError: Object #<Object> has no method 'init'

Any help would be appreciated, thank you!

@Chrysweel
Copy link

Hello. This is my configuration and it works, I hope help you!

module.exports = function(grunt) {
    var folder = 'v0.1';
    grunt.initConfig({
        // Run your source code through JSHint's defaults.
        jshint: ["app/**/*.js"],

        //start grunt s3
        s3: {
            options: {
                key: 'my-key',
                secret: 'my-secret',
                bucket: 'name-my-bucket',
                access: 'public-read',
                headers: {
                    // Two Year cache policy (1000 * 60 * 60 * 24 * 730)
                    "Cache-Control": "max-age=630720000, public",
                    "Expires": new Date(Date.now() + 63072000000).toUTCString()
                }
            },
            dev: {
                // These options override the defaults
                options: {
                    encodePaths: false,
                    //max number of concurrent transfers - if not specified or set to 0, will be unlimited
                    maxOperations: 20
                },
                // Files to be uploaded.
                upload: [
                    {
                   //folder I want to upload
                        src: 'www-built/**/*',
                    //folder of destinity
                        dest: "/"+folder+"/",
                  // path relative to my folder origin
                        rel: '/var/www/my-project/',
                        options: { gzip: true }
                    },
                ],
            }

        }
        //finish grunts3

    });

    // Grunt contribution tasks.
    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks('grunt-s3');        

    // When running the default Grunt command, just lint the code.
    grunt.registerTask("default", [
        "jshint",
    ]);
};

@pifantastic
Copy link
Owner

@gerrymiller I think what you're missing is: src: 'dist/**/*'

Note the extra /*

@gerrymiller
Copy link
Author

Thanks for the responses @Chrysweel and @pifantastic. If found and fixed the problem - it seems it was actually caused by the encodePaths: true option. My working config file:

s3: {
  options: {
    key: 'access key',
    secret: 'secret key',
    bucket: 'myBucket',
    access: 'public-read',
    gzip: true,
    gzipExclude: ['.jpg', '.jpeg.', '.ico', '.gif', '.txt'],
    headers: {
      // Two Year cache policy (1000 * 60 * 60 * 24 * 730)
      //'Cache-Control': 'max-age=630720000, public',
      //'Expires': new Date(Date.now() + 63072000000).toUTCString()
    }
  },
  dist: {
    upload: [{
      src: 'dist/**/*.*',
      dest: '/',
      rel: 'dist'
    } ]
  }
}

I'm still seeing this error whenever I run grunt, even if I'm not running the s3 task:

Loading "s3.js" tasks...ERROR
>> TypeError: Object #<Object> has no method 'init'

It seems benign in that the builds still work, but I'm wondering if anyone has any idea about where this is coming from, and (hopefully) how I can make it go away.

And finally, THANK YOU @pifantastic for this awesome tool, it's really helped speed up my workflow!

@orthodoc
Copy link

Its not working for me.

I get exactly the same error irrespective of whether I run it in isolation or as part of the build task.

Loading "s3.js" tasks...ERROR
    >> TypeError: Object #<Object> has no method 'init'

The build task runs successfully, but the s3 task is not accomplishing anything, ie: nothing is gettting uploaded to s3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants