aws.s3 (version 0.3.21)

s3write_using: Custom read and write

Description

Read/write objects from/to S3 using a custom function

Usage

s3write_using(x, FUN, ..., object, bucket, opts = NULL)

s3read_using(FUN, ..., object, bucket, opts = NULL, filename = NULL)

Arguments

x

For s3write_using, a single R object to be saved via the first argument to FUN and uploaded to S3.

FUN

For s3write_using, a function to which x and a file path will be passed (in that order).

...

Additional arguments to FUN

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”.

opts

Optional additional arguments passed to put_object or save_object, respectively.

filename

Optional string, name of the temporary file that will be created. If not specified, tempfile() with the extension of the object is used.

Value

For s3write_using, a logical, invisibly. For s3read_using, the output of FUN applied to the file from object.

See Also

s3saveRDS, s3readRDS, put_object,get_object

Examples

Run this code
# NOT RUN {
library("datasets")
# create bucket
b <- put_bucket("myexamplebucket")

# save a dataset to the bucket as a csv
if (require("utils")) {
  s3write_using(mtcars, FUN = write.csv, object = "mtcars.csv", bucket = b)
}

# load dataset from the bucket as a csv
if (require("utils")) {
  s3read_using(FUN = read.csv, object = "mtcars.csv", bucket = b)
}

# cleanup
delete_object(object = "mtcars.csv", bucket = b)
delete_bucket(bucket = b)
# }

Run the code above in your browser using DataLab