s3GenerateURI

Builds an unsigned URI for an S3 bucket or object, without making a request.

s3GenerateURI(bucketNameOrPath [, objectName, type, secure, accessKeyId, secretAccessKey, host, timeout]) → returns string

Argument Reference

bucketNameOrPath string
Required

The bucket name, or an s3:// path to a bucket or object, such as s3://mybucket/file.txt.

objectName string

The object key, when bucketNameOrPath is a bucket name.

type string
Default: virtualhost

The URI style: virtualhost, path, arn or s3.

secure boolean
Default: true

When true, an https URI is built. Only applies to virtualhost and path.

accessKeyId string

The S3 access key ID. Defaults to the lucee.s3.accesskeyid system property or environment variable.

secretAccessKey string

The S3 secret access key. Defaults to the lucee.s3.secretaccesskey system property or environment variable.

host string

The hostname of an S3-compatible provider, without https://. Defaults to Amazon AWS.

timeout numeric
Default: 10000

The timeout in milliseconds.

Compatibility

Lucee:

Requires the S3 extension.

RustCFML:

Names the first two arguments bucket and object, and the type argument style, which can be virtualhost or path. Takes no credential or timeout arguments, so host is the fifth argument.

Examples
Sample code invoking the s3GenerateURI function

Virtual-host style against the default endpoint.

uri = s3GenerateURI("my-bucket", "reports/q3.pdf");

Expected Result: https://my-bucket.s3.amazonaws.com/reports/q3.pdf

Builds a URI with the bucket in the path instead of the hostname.

uri = s3GenerateURI("my-bucket", "reports/q3.pdf", "path");

Expected Result: https://minio.example.com/my-bucket/reports/q3.pdf

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

Fork me on GitHub