MathieuLoutre / grunt-aws-s3

Grunt plugin to interact with AWS S3 using the AWS SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

action: 'delete' - Fatal error: Failed to list content of bucket <bucket> NoSuchKey: The specified key does not exist.

IainAndrew opened this issue · comments

I have this task working perfectly for uploading, but I can't seem to be able to delete files from my bucket. I get this error when running grunt aws_s3:clean:

Fatal error: Failed to list content of bucket <bucket>
NoSuchKey: The specified key does not exist.

Here's my task config:

aws: grunt.file.readJSON('aws-keys.json'),

aws_s3: {
  options: {
    accessKeyId: '<%= aws.AWSAccessKeyId %>',
    secretAccessKey: '<%= aws.AWSSecretKey %>',
    region: 'eu-west-1',
    uploadConcurrency: 5,
    downloadConcurrency: 5,
    bucket: '<bucket>'
  },
  deploy: {
    files: [{
      expand: true, 
      cwd: 'dist', 
      src: [
        '**/*'
      ], 
      dest: ''
    }]
  },
  clean: {
    options: {
      debug: true
    },
    files: [{
      dest: '/', 
      action: 'delete'
    }]
  }
}

My mistake. I didn't realise having debug: true prevented it from performing the action. It also didn't like the fact that bucket was set to 'bucketname/foldername', though it worked fine with the deploy task for some reason!

Sorry for the late reply, entirely missed that notification. It might (certainly) be related to some changes that have been made in mock-aws-s3 a few weeks ago. It was related to the the naming of the bucket, so it's likely. debug: true indeed doesn't perform the action, just does a "dry" run.

Did your bucket string have any characters outside of [a-zA-Z]?

My bucket string was basically 'bucket-name/directory-name'. The upload task was fine with having a subdirectory in bucket but the delete task was not. So I ended up just having bucket be the bucket name, and putting the subdirectory as the dest of both tasks.

Interesting, thanks! Must be a weird path calculation in the mock library. I'll have a look.

It's a tiny issue really, but thanks for taking a look :)

The mock library has been updated (but on this module yet) so I'm hoping this issue will be solved! Otherwise, feel free to re-open.