s3Exists

Tests whether an S3 (or S3-compatible) bucket, or a specific object within a bucket, exists.

s3Exists(bucket [, object, accessKeyId, secretKey, host]) → returns boolean

This function requires RustCFML.  Not supported on Lucee, Adobe ColdFusion, etc.

Argument Reference

bucket string
Required

The name of the S3 bucket to test.

object string

The object key to test. When omitted, the bucket itself is tested.

accessKeyId string

Inline AWS access key id. Overrides credentials from Application.cfc and environment variables.

secretKey string

Inline AWS secret access key.

host string

Inline endpoint URL for S3-compatible providers (e.g. Cloudflare R2, MinIO).

Examples
Sample code invoking the s3Exists function

Returns true if the key is present in the bucket.

if ( s3Exists("my-bucket", "logs/today.txt") ) { }

Without an object argument, tests the bucket itself.

present = s3Exists("my-bucket");

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub