Automattic / Automattic/knox

Allow head requests for S3 buckets

Open
#309 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.7k
Forks
283
PR merge metrics
No merged PRs in 30d

Description

I am simply trying to do a head request to check the existence of an S3 Bucket.

If I were using the aws-sdk, I would use the [aws-sdk's `headObject`](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#headObject-property) method and do this:

``` js
var AWS = require('aws-sdk');
var s3 = new AWS.S3();

s3.headObject({Bucket: 'someBucket'}, function(err, data) {
if (err) {
console.log(err, err.stack);
} else {
console.log('The bucket exists!');
}
});
```

I see that knox has a `client.head()` method, which seems to need a path to a file, like this:

``` js
client.head('path/to/file').on('response', function (res) {
// ...
});
```

But is there a way to use knox to just grab the HEAD of a bucket?

Something like:

``` js
client.head('bucketName').on('response', function (res) {
// ...
});
```

Thanks!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the existing client.head() entry point, using the AWS SDK headObject example in the issue as the expected behavior. Done means a bucket-only HEAD request is accepted and its response can distinguish whether the bucket exists.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript
Domain
cloud
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.