Skip to contents

Upload a folder of files to create an S3 bucket

Usage

aws_bucket_upload(
  path,
  bucket,
  max_batch = fs::fs_bytes("100MB"),
  force = FALSE,
  ...
)

Arguments

path

(character) local path to a directory. required

bucket

(character) bucket name. required

max_batch

(fs_bytes) maximum batch size being uploaded with each multipart

force

(logical) force deletion without going through the prompt. default: FALSE. Should only be set to TRUE when required for non-interactive use.

...

named parameters passed on to s3fs::s3_dir_upload()

Value

the s3 format path of the bucket uploaded to

Details

To upload individual files see aws_file_upload()

Note

Requires the env var AWS_REGION. This function prompts you to make sure that you want to delete the bucket.

Examples

if (FALSE) { # interactive()
library(fs)
tdir <- path(tempdir(), "apples")
dir.create(tdir)
tfiles <- replicate(n = 10, file_temp(tmp_dir = tdir, ext = ".txt"))
invisible(lapply(tfiles, function(x) write.csv(mtcars, x)))

bucket_name <- random_string("bucket")
if (!aws_bucket_exists(bucket_name)) aws_bucket_create(bucket_name)
aws_bucket_upload(path = tdir, bucket = bucket_name)
aws_bucket_list_objects(bucket_name)

# cleanup
objs <- aws_bucket_list_objects(bucket_name)
aws_file_delete(objs$uri)
aws_bucket_list_objects(bucket_name)
aws_bucket_delete(bucket_name, force = TRUE)
aws_bucket_exists(bucket_name)
}