Skip to contents

Builds a public HTTPS URL for any object in your Spaces buckets, optionally presigning it (for private buckets) or checking that it exists.

Usage

cdn_asset_url(
  bucket = c("art-public", "art-coa", "art-data", "art-vault"),
  key = "",
  signed = TRUE,
  check = FALSE
)

Arguments

bucket

Character(1). One of your Spaces buckets: `"art-public"`, `"art-coa"`, `"art-data"`, `"art-vault"`.

key

Character(1). The object key/path inside the bucket, e.g. `"thumbnails/.../img.png"`. May be `""` to hit the bucket root.

signed

Logical(1). `TRUE` to generate a presigned URL (requires CDN credentials; see README.md), or `FALSE` to build a plain URL. Defaults to `TRUE`.

check

Logical(1). If `TRUE`, performs an HTTP HEAD on the resulting URL and errors if the status is >= 400. Defaults to `FALSE`.

Value

Character(1). A valid HTTPS URL. If `check = TRUE` this will have been HEAD-verified to return HTTP 200.

Details

- Bucket `"art-public"` is public-read, so any URL (signed or not) is returned unsigned. - Buckets `"art-coa"`, `"art-data"`, and `"art-vault"` are private and require valid CDN credentials to presign (see README.md).

See also

Examples

if (FALSE) { # \dontrun{
# public asset (no creds needed)
url1 <- cdn_asset_url("art-public", "thumbnails/foo.png",
  signed = FALSE, check = TRUE
)

# private asset (presigned, 1 h expiry)
url2 <- cdn_asset_url("art-data",
  "processed/artist/artwork/img.png",
  signed = TRUE, check = TRUE
)
browseURL(url2)
} # }