s3GetMetaData

Returns the metadata for an S3 (or S3-compatible) object: content_type, content_length, etag, last_modified, storage_class and any x-amz-meta-* headers. Accepts either a bucket and object, or a single s3:// URL as the first argument.

s3GetMetaData(bucket, object [, accessKeyId, secretKey, host]) or s3GetMetaData(s3url [, accessKeyId, secretKey, host]) → returns struct

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

Argument Reference

bucket string
Required

The name of the S3 bucket, or a full s3:// URL.

object string

The object key to inspect. Omitted when the first argument is an s3:// URL.

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 s3GetMetaData function

Returns a struct with the object's metadata.

meta = s3GetMetaData("my-bucket", "logs/today.txt");

Passing an s3:// URL as the first argument addresses the object directly.

meta = s3GetMetaData("s3://my-bucket/logs/today.txt");

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

Fork me on GitHub