I am trying to check if a file exists on s3 through Rstudio on Amazon EC2 instance. Base R's exists()
function and file.exists()
functions are returning FALSE
for every file. Following is my code, exists.type
exists in s3 and not_exists.type
does not exist.
library("aws.s3")
Sys.setenv("AWS_ACCESS_KEY_ID" = "key1",
"AWS_SECRET_ACCESS_KEY" = "key2",
"AWS_DEFAULT_REGION" = "key3"
)
existing_file_path = "s3://bucket_name/folder_name/exists.type"
not_existing_file_path = "s3://bucket_name/folder_name/not_exists.type"
exists(existing_file_path) #returns FALSE
exists(not_existing_file_path) #returns FALSE
file.exists(existing_file_path) returns FALSE
file.exists(not_existing_file_path) returns FALSE
aws.s3::get_object(existing_file_path) #reads the entire file
aws.s3::get_object(not_existing_file_path) #gives error
I tried list.files
also, it returns character(0)
.