Check if an object from an S3 bucket exists. To retrieve the object, see get_object
head_object(object, bucket, ...)
object_exists(object, bucket, ...)
object_size(object, bucket, ...)
Character string with the object key, or an object of class “s3_object”. In most cases, if object
is specified as the latter, bucket
can be omitted because the bucket name will be extracted from “Bucket” slot in object
.
Character string with the name of the bucket, or an object of class “s3_bucket”.
Additional arguments passed to s3HTTP
.
head_object
returns a logical. object_exists
returns TRUE
if bucket exists and is accessible, else FALSE
. object_size
returns an integer, which is NA
if the request fails.
head_object
is a low-level API wrapper that checks whether an object exists by executing an HTTP HEAD request; this can be useful for checking object headers such as “content-length” or “content-type”. object_exists
is sugar that returns only the logical.
object_size
returns the size of the object (from the “content-length” attribute returned by head_object
).
if (FALSE) { # \dontrun{
# get an object in memory
## create bucket
b <- put_bucket("myexamplebucket")
## save a dataset to the bucket
s3save(mtcars, bucket = b, object = "mtcars")
# check that object exists
object_exists("mtcars", "myexamplebucket")
object_exists("s3://myexamplebucket/mtcars")
# get the object's size
object_size("s3://myexamplebucket/mtcars")
# get the object
get_object("s3://myexamplebucket/mtcars")
} # }