Created
May 6, 2019 12:33
-
-
Save jamespaultg/ddc37fb811409cbc49f6c29ac3a9bf29 to your computer and use it in GitHub Desktop.
Access AWS S3 objects from R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require("devtools") | |
| install.packages("aws.s3", repos = c("cloudyr" = "http://cloudyr.github.io/drat")) | |
| library("aws.s3") | |
| # set the environment parameters | |
| Sys.setenv("AWS_ACCESS_KEY_ID" = "Key_id", | |
| "AWS_SECRET_ACCESS_KEY" = "secret_access_key", | |
| "AWS_DEFAULT_REGION" = "region") | |
| fileslist <- get_bucket_df(bucket = "bucket-name") | |
| # save the file locally | |
| save_object(fileslist$Key, bucket = "bucket-name") | |
| lapply(fileslist, function(x) { save_object(x, bucket = 'bucket-name')}) | |
| # save the local file to S3 bucket | |
| s3save(RdataObject, object="file.csv", bucket = 'bucket-name') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment