Get a csv file from s3:
aws.signature::use_credentials(profile = "rstudio")
library("aws.s3")
bucketlist()
wanted_bucket = "testbucket"
wanted_file = "/test.csv"
bkt <- get_bucket(wanted_bucket)
print(bkt)
obj <- get_object(wanted_file, wanted_bucket, check_region = F)
c <- rawToChar(obj)
print(c)
In the the ~/.aws/credentials
file:
[rstudio]
aws_secret_access_key = ***
aws_access_key_id = ***
aws_default_region = eu-west-2
If we didn't put check_region = F
everything went danish and failed with:
Error in parse_aws_s3_response(r, Sig, verbose = verbose) :
Forbidden (HTTP 403)
This was very confusing because the lines:
bkt <- get_bucket(wanted_bucket)
print(bkt)
worked properly and listed the contents of the bucket and the aws s3 cp command worked outside of R studio.
See this issue from cloudyr cloudyr/aws.s3#175