Skip to contents

Serializes a local R object to a temporary file and uploads it to S3 using the paws library SDK. If the object is large (> 2 GB by default), the function automatically performs a multipart upload to avoid curl::postfieldsize overflow errors.

Usage

paws_write_object(
  x,
  bucket,
  path,
  save_fun = readr::write_rds,
  overwrite = TRUE,
  verbose = FALSE,
  multipart_threshold = 2 * 1024^3,
  part_size = 300 * 1024^2
)

Arguments

x

Object to upload.

bucket

Character scalar. Name of the S3 bucket.

path

Character scalar. Full S3 key (path inside the bucket).

save_fun

Function used to serialize the object before upload. Defaults to base::saveRDS().

overwrite

Logical. If FALSE, aborts if the object already exists. Default is TRUE.

verbose

Logical. If TRUE, prints informational messages.

multipart_threshold

Numeric scalar. File size (in bytes) above which multipart upload is used. Default is 2 GB.

part_size

Numeric scalar. Size (in bytes) of each multipart chunk. Default is 100 MB.

Value

Invisibly returns TRUE if upload succeeds.

Examples

if (FALSE) { # \dontrun{
paws_write_object(
  x = mtcars,
  bucket = "g6tr-dl-test",
  path = "project/data/srv_main/.rds",
  verbose = TRUE
)
} # }