Description Usage Arguments Details Value References See Also Examples
Retrieve an object from an S3 bucket
1 2 3 4 5 6 | get_object(object, bucket, use_https, ...)
save_object(object, bucket, file = basename(object), overwrite = TRUE,
use_https, ...)
head_object(object, bucket, use_https, ...)
|
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 |
file |
An R connection, or file name specifying the local file to save the object into. |
overwrite |
A logical indicating whether to overwrite |
use_https |
True if connection is HTTPS and False if connection is HTTP |
get_object
retrieves an object into memory as a raw vector. save_object
saves an object to a local file. head_object
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”.
Some users may find the raw vector response format of get_object
unfamiliar. The object will also carry attributes, including “content-type”, which may be useful for deciding how to subsequently process the vector. Two common strategies are as follows. For text content types, running charToRaw
may be the most useful first step to make the response human-readable. Alternatively, converting the raw vector into a connection using rawConnection
may also be useful, as that can often then be passed to parsing functions just like a file connection would be.
If file = NULL
, a raw object. Otherwise, a character string containing the file name that the object is saved to.
API Documentation: GET Object torrent
get_bucket
, put_object
, delete_object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## 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")
obj <- get_bucket(b)
## get the object in memory
x <- get_object(obj[[1]])
load(rawConnection(x))
"mtcars" %in% ls()
# save an object locally
y <- save_object(obj[[1]], file = object[[1]][["Key"]])
y %in% dir()
# return object using 'S3 URI' syntax
get_object("s3://myexamplebucket/mtcars")
# return parts of an object
## use 'Range' header to specify bytes
get_object(object = obj[[1]], headers = list('Range' = 'bytes=1-120'))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.