s3Delete

Deletes an S3 (or S3-compatible) bucket or a single object. Without an object argument the bucket itself is deleted; with an object argument the single key is deleted. Deleting a non-empty bucket requires force=true, which empties the bucket first.

s3Delete(bucket [, object, force, accessKeyId, secretKey, host]) → returns void

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

Argument Reference

bucket string
Required

The name of the S3 bucket to delete, or the bucket containing the object.

object string

The object key to delete. When omitted, the bucket itself is deleted.

force boolean
Default: false

When deleting a bucket, true empties the bucket first. Defaults to false.

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

Removes one key from the bucket.

s3Delete("my-bucket", "logs/today.txt");

force=true empties the bucket before deleting it.

s3Delete("my-bucket", "", true);

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

Fork me on GitHub