File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -600,6 +600,28 @@ Returns an `EventEmitter` with these events:
600600 * ` 'copySuccess' (data) `
601601 * ` 'end' (data) `
602602
603+ ## Examples
604+
605+ ### Check if a file exists in S3
606+
607+ Using the AWS SDK, you can send a HEAD request, which will tell you if a file exists at ` Key ` .
608+
609+ See http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#headObject-property
610+
611+ ``` js
612+ var client = require (' s3' ).createClient ({ /* options */ });
613+ client .s3 .headObject ({
614+ Bucket: ' s3 bucket name' ,
615+ Key: ' some/remote/file'
616+ }, function (err , data ) {
617+ if (err) {
618+ // file does not exist (err.statusCode == 404)
619+ return ;
620+ }
621+ // file exists
622+ });
623+ ```
624+
603625## Testing
604626
605627` S3_KEY=<valid_s3_key> S3_SECRET=<valid_s3_secret> S3_BUCKET=<valid_s3_bucket> npm test `
You can’t perform that action at this time.
0 commit comments