aws_file_exists: Check if a file exists

View source: R/files.R

aws_file_existsR Documentation

Check if a file exists

Description

Check if a file exists

Usage

aws_file_exists(remote_path)

Arguments

remote_path

(character) one or more remote S3 paths. required

Value

vector of booleans (TRUE or FALSE), length matches length(remote_path)

See Also

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

Examples


library(glue)
bucket <- random_bucket()
aws_bucket_create(bucket)

# upload some files
tfiles <- replicate(n = 3, tempfile())
paths <- s3_path(bucket, glue("{basename(tfiles)}.txt"))
for (file in tfiles) cat("Hello saturn!!!!!!\n", file = file)
for (file in tfiles) print(readLines(file))
aws_file_upload(path = tfiles, remote_path = paths)

# check that files exist
aws_file_exists(paths[1])
aws_file_exists(paths[2])
aws_file_exists(s3_path(bucket, "doesnotexist.txt"))

# Cleanup
six_bucket_delete(bucket, force = TRUE)


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