Skip to contents

Takes care of deleting bucket objects, so that the bucket itself can be deleted cleanly

Usage

six_bucket_delete(bucket, force = FALSE, ...)

Arguments

bucket

(character) bucket name. required

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 delete_bucket

Value

NULL, invisibly

What is magical

  • Exits early if bucket does not exist

  • Checks for any objects in the bucket and deletes any present

  • Deletes bucket after deleting objects

Examples

if (FALSE) { # interactive()
# bucket does not exist
six_bucket_delete("notabucket")

# bucket exists w/o objects
bucket <- random_string("bucket")
aws_bucket_create(bucket)
six_bucket_delete(bucket)

# bucket exists w/ objects (files and directories with files)
bucket <- random_string("bucket")
aws_bucket_create(bucket)
demo_rds_file <- file.path(system.file(), "Meta/demo.rds")
links_file <- file.path(system.file(), "Meta/links.rds")
aws_file_upload(
  c(demo_rds_file, links_file),
  s3_path(bucket, c(basename(demo_rds_file), basename(links_file)))
)
aws_file_upload(
  c(demo_rds_file, links_file),
  s3_path(
    bucket, "newfolder",
    c(basename(demo_rds_file), basename(links_file))
  )
)
aws_bucket_list_objects(bucket)
six_bucket_delete(bucket)
}