aws_file_copy: Copy files between buckets

View source: R/files.R

aws_file_copyR Documentation

Copy files between buckets

Description

Copy files between buckets

Usage

aws_file_copy(remote_path, bucket, force = FALSE, ...)

Arguments

remote_path

(character) one or more remote S3 paths. required

bucket

(character) bucket to copy files to. required. if the bucket does not exist we prompt you asking if you'd like the bucket to be created

force

(logical) force bucket creation 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_file_copy()

Value

vector of paths, length matches length(remote_path)

See Also

Other files: aws_file_attr(), aws_file_delete(), aws_file_download(), aws_file_exists(), aws_file_rename(), aws_file_upload(), six_file_upload()

Examples


bucket1 <- random_bucket()
aws_bucket_create(bucket1)

# create files in an existing bucket
tfiles <- replicate(n = 3, tempfile())
for (i in tfiles) cat("Hello\nWorld\n", file = i)
paths <- s3_path(bucket1, c("aaa", "bbb", "ccc"), ext = "txt")
aws_file_upload(tfiles, paths)

# create a new bucket
bucket2 <- random_bucket()
new_bucket <- aws_bucket_create(bucket = bucket2)

# add existing files to the new bucket
aws_file_copy(paths, bucket2)

# or, create a bucket that doesn't exist yet
bucket3 <- random_bucket()
aws_file_copy(paths, bucket3, force = TRUE)

# Cleanup
six_bucket_delete(bucket1, force = TRUE)
six_bucket_delete(bucket2, force = TRUE)
six_bucket_delete(bucket3, force = TRUE)


sixtyfour documentation built on April 3, 2025, 8:22 p.m.