Using R with S3

Oct 20, 2015 in other

#R#S3#EC2

Amazon S3 is great in many ways. It is very easy to use and it works well with R. I have recently came across this package by [Gastrograph] https://github.com/Gastrograph/RS3. You can literially get this up and running in few line. All you need is:

The author mentions that the tool is not functional in either MAC OS or Windows. There is also a requirement to have libxml2-dev and libcurl3-dev is installed. Although if you have curl or xml packages installed correctly you should be OK.

Now here are the steps to get this up and running:

Install the packages from Github as the package is not on cran.

if needed:

install.packages("httr")
install.packages("devtools")

Now install the package RS3 from github:

require(httr) 
install_github("Gastrograph/RS3")

If everything goes well, you are ready to play:

S3_connect("<my-access-key>","<my-secret-key>")
# you can find this under IAM Management Console --> your name in the upper right --> creat access key
S3_create_bucket("test-bucket","public-read")
# here you should see message saying: initialized correctly....

Now you are connected to S3 bucket you can get and put files from the repository.

file <- "path to the file"
# This function Uploads files to S3 
S3_put_object("test-bucket","myfile.csv",file,"text/csv")
# This function downloads the file from S3 
S3_get_object("test-bucket","myfile.csv","path-to-the-local-file")

Overall this is a great package that streamlines working with S3. I only hope to see the MAC OS and Windows versions.