Skip to content
This repository has been archived by the owner on Feb 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #107 from gswalden/patch-1
Browse files Browse the repository at this point in the history
add examples section to README.md w/ check if file exists
  • Loading branch information
faceleg committed Nov 20, 2015
2 parents 51c4fec + d368d8f commit d0946f6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,28 @@ Returns an `EventEmitter` with these events:
* `'copySuccess' (data)`
* `'end' (data)`

## Examples

### Check if a file exists in S3

Using the AWS SDK, you can send a HEAD request, which will tell you if a file exists at `Key`.

See http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#headObject-property

```js
var client = require('s3').createClient({ /* options */ });
client.s3.headObject({
Bucket: 's3 bucket name',
Key: 'some/remote/file'
}, function(err, data) {
if (err) {
// file does not exist (err.statusCode == 404)
return;
}
// file exists
});
```

## Testing

`S3_KEY=<valid_s3_key> S3_SECRET=<valid_s3_secret> S3_BUCKET=<valid_s3_bucket> npm test`
Expand Down

0 comments on commit d0946f6

Please sign in to comment.