head_object {aws.s3} | R Documentation |
Get object metadata
Description
Check if an object from an S3 bucket exists. To retrieve the object, see get_object
Usage
head_object(object, bucket, ...)
object_exists(object, bucket, ...)
object_size(object, bucket, ...)
Arguments
object |
Character string with the object key, or an object of class “s3_object”. In most cases, if |
bucket |
Character string with the name of the bucket, or an object of class “s3_bucket”. |
... |
Additional arguments passed to |
Details
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
).
Value
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.
References
API Documentation: HEAD Object
See Also
bucket_exists
, get_object
, put_object
, delete_object
Examples
## Not run:
# 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")
## End(Not run)