head_object: Get object metadata

Description Usage Arguments Details Value References See Also Examples

View source: R/head_object.R

Description

Check if an object from an S3 bucket exists. To retrieve the object, see get_object

Usage

1
2
3
4
5
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 object is specified as the latter, bucket can be omitted because the bucket name will be extracted from “Bucket” slot in object.

bucket

Character string with the name of the bucket, or an object of class “s3_bucket”.

...

Additional arguments passed to s3HTTP.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## 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)

aws.s3 documentation built on April 14, 2020, 5:15 p.m.